Changeset 540 in SHVCSoftware for trunk/source/Lib
- Timestamp:
- 9 Jan 2014, 05:04:17 (11 years ago)
- Location:
- trunk
- Files:
-
- 55 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/SHM-4.1-dev (added) merged: 501-539 /trunk merged: 499
- Property svn:mergeinfo changed
-
trunk/source
- Property svn:mergeinfo changed
/branches/SHM-4.1-dev/source (added) merged: 502-522,524-533,535,537-539
- Property svn:mergeinfo changed
-
trunk/source/Lib/TAppCommon/program_options_lite.cpp
r313 r540 38 38 #include <list> 39 39 #include <map> 40 #include <algorithm> 40 41 #include "program_options_lite.h" 41 42 -
trunk/source/Lib/TLibCommon/CommonDef.h
r499 r540 40 40 41 41 #include <algorithm> 42 43 42 #if _MSC_VER > 1000 44 43 // disable "signed and unsigned mismatch" … … 57 56 58 57 #if SVC_EXTENSION 59 #define NV_VERSION "4.0" ///< Current software version 58 #include <vector> 59 #define NV_VERSION "4.1" ///< Current software version 60 60 #else 61 #define NV_VERSION "12. 0" ///< Current software version61 #define NV_VERSION "12.1" ///< Current software version 62 62 #endif 63 63 … … 209 209 210 210 NAL_UNIT_CODED_SLICE_TSA_N, // 2 211 NAL_UNIT_CODED_SLICE_T LA_R, // 3211 NAL_UNIT_CODED_SLICE_TSA_R, // 3 212 212 213 213 NAL_UNIT_CODED_SLICE_STSA_N, // 4 … … 280 280 }; 281 281 282 #if OUTPUT_LAYER_SET_INDEX 283 class CommonDecoderParams 284 { 285 Int m_targetLayerId; 286 Int m_outputLayerSetIdx; 287 std::vector<Int> *m_targetDecLayerIdSet; 288 Bool m_valueCheckedFlag; 289 public: 290 CommonDecoderParams(): 291 m_targetLayerId(0) 292 , m_outputLayerSetIdx(-1) 293 , m_targetDecLayerIdSet(NULL) 294 , m_valueCheckedFlag(false) 295 {} 296 297 Void setTargetLayerId(const Int x) { m_targetLayerId = x; } 298 Int getTargetLayerId() { return m_targetLayerId;} 299 300 Void setOutputLayerSetIdx(const Int x) { m_outputLayerSetIdx = x; } 301 Int getOutputLayerSetIdx() { return m_outputLayerSetIdx;} 302 303 Void setTargetDecLayerIdSet(std::vector<Int> *x) { m_targetDecLayerIdSet = x; } 304 std::vector<Int>* getTargetDecLayerIdSet() { return m_targetDecLayerIdSet;} 305 306 Void setValueCheckedFlag(const Bool x) { m_valueCheckedFlag = x; } 307 Bool getValueCheckedFlag() { return m_valueCheckedFlag;} 308 309 }; 310 #endif 282 311 //! \} 283 312 -
trunk/source/Lib/TLibCommon/NAL.h
r313 r540 76 76 return m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R 77 77 || m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N 78 || m_nalUnitType == NAL_UNIT_CODED_SLICE_T LA_R78 || m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_R 79 79 || m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N 80 80 || m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_R -
trunk/source/Lib/TLibCommon/TComDataCU.cpp
r494 r540 309 309 } 310 310 } 311 311 #if !HM_CLEANUP_SAO 312 312 const NDBFBlockInfo& NDBFBlockInfo::operator= (const NDBFBlockInfo& src) 313 313 { … … 328 328 } 329 329 330 330 #endif 331 331 // ==================================================================================================================== 332 332 // Public member functions … … 3638 3638 return getPic()->getPicSym()->getInverseCUOrderMap(m_uiCUAddr)*(1<<(m_pcSlice->getSPS()->getMaxCUDepth()<<1))+m_uiAbsIdxInLCU; 3639 3639 } 3640 3640 #if !HM_CLEANUP_SAO 3641 3641 /** Set neighboring blocks availabilities for non-deblocked filtering 3642 3642 * \param numLCUInPicWidth number of LCUs in picture width … … 4008 4008 } 4009 4009 4010 #endif 4011 4010 4012 #if SVC_EXTENSION 4011 4013 TComDataCU* TComDataCU::getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int iMotionMapping ) … … 4028 4030 #endif 4029 4031 4032 #if O0098_SCALED_REF_LAYER_ID 4033 Int leftStartL = getSlice()->getSPS()->getScaledRefLayerWindowForLayer(getSlice()->getVPS()->getRefLayerId(getSlice()->getLayerId(), refLayerIdc)).getWindowLeftOffset(); 4034 Int topStartL = getSlice()->getSPS()->getScaledRefLayerWindowForLayer(getSlice()->getVPS()->getRefLayerId(getSlice()->getLayerId(), refLayerIdc)).getWindowTopOffset(); 4035 #else 4030 4036 Int leftStartL = this->getSlice()->getSPS()->getScaledRefLayerWindow(refLayerIdc).getWindowLeftOffset(); 4031 4037 Int topStartL = this->getSlice()->getSPS()->getScaledRefLayerWindow(refLayerIdc).getWindowTopOffset(); 4038 #endif 4032 4039 Int iBX = ((uiPelX - leftStartL)*g_posScalingFactor[refLayerIdc][0] + (1<<15)) >> 16; 4033 4040 Int iBY = ((uiPelY - topStartL )*g_posScalingFactor[refLayerIdc][1] + (1<<15)) >> 16; -
trunk/source/Lib/TLibCommon/TComDataCU.h
r494 r540 55 55 //! \{ 56 56 57 #if !HM_CLEANUP_SAO 57 58 // ==================================================================================================================== 58 59 // Non-deblocking in-loop filter processing block data structure … … 92 93 const NDBFBlockInfo& operator= (const NDBFBlockInfo& src); //!< "=" operator 93 94 }; 95 #endif 94 96 95 97 … … 159 161 Pel* m_pcIPCMSampleCr; ///< PCM sample buffer (Cr) 160 162 163 #if !HM_CLEANUP_SAO 161 164 Int* m_piSliceSUMap; ///< pointer of slice ID map 162 165 std::vector<NDBFBlockInfo> m_vNDFBlock; 163 166 #endif 164 167 // ------------------------------------------------------------------------------------------------------------------- 165 168 // neighbour access variables … … 389 392 Void setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth); 390 393 394 #if !HM_CLEANUP_SAO 391 395 /// get slice ID for SU 392 396 Int getSUSliceID (UInt uiIdx) {return m_piSliceSUMap[uiIdx]; } … … 403 407 ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary 404 408 ,Bool bIndependentTileBoundaryEnabled ); 409 #endif 405 410 // ------------------------------------------------------------------------------------------------------------------- 406 411 // member functions for accessing partition information -
trunk/source/Lib/TLibCommon/TComPic.cpp
r494 r540 59 59 , m_bNeededForOutput (false) 60 60 , m_uiCurrSliceIdx (0) 61 #if !HM_CLEANUP_SAO 61 62 , m_pSliceSUMap (NULL) 62 63 , m_pbValidSlice (NULL) … … 65 66 , m_bIndependentTileBoundaryForNDBFilter (false) 66 67 , m_pNDBFilterYuvTmp (NULL) 68 #endif 67 69 , m_bCheckLTMSB (false) 68 70 { … … 212 214 } 213 215 } 214 216 #if HM_CLEANUP_SAO 217 Bool TComPic::getSAOMergeAvailability(Int currAddr, Int mergeAddr) 218 { 219 Bool mergeCtbInSliceSeg = (mergeAddr >= getPicSym()->getCUOrderMap(getCU(currAddr)->getSlice()->getSliceCurStartCUAddr()/getNumPartInCU())); 220 Bool mergeCtbInTile = (getPicSym()->getTileIdxMap(mergeAddr) == getPicSym()->getTileIdxMap(currAddr)); 221 return (mergeCtbInSliceSeg && mergeCtbInTile); 222 } 223 #else 215 224 /** Create non-deblocked filter information 216 225 * \param pSliceStartAddress array for storing slice start addresses … … 548 557 549 558 } 559 #endif 550 560 551 561 #if SVC_EXTENSION -
trunk/source/Lib/TLibCommon/TComPic.h
r494 r540 75 75 Bool m_bNeededForOutput; 76 76 UInt m_uiCurrSliceIdx; // Index of current slice 77 #if !HM_CLEANUP_SAO 77 78 Int* m_pSliceSUMap; 78 79 Bool* m_pbValidSlice; … … 81 82 Bool m_bIndependentTileBoundaryForNDBFilter; 82 83 TComPicYuv* m_pNDBFilterYuvTmp; //!< temporary picture buffer when non-cross slice/tile boundary in-loop filtering is enabled 84 #endif 83 85 Bool m_bCheckLTMSB; 84 86 … … 199 201 Window& getDefDisplayWindow() { return m_defaultDisplayWindow; } 200 202 203 #if HM_CLEANUP_SAO 204 Bool getSAOMergeAvailability(Int currAddr, Int mergeAddr); 205 #else 201 206 Void createNonDBFilterInfo (std::vector<Int> sliceStartAddress, Int sliceGranularityDepth 202 207 ,std::vector<Bool>* LFCrossSliceBoundary … … 211 216 TComPicYuv* getYuvPicBufferForIndependentBoundaryProcessing() {return m_pNDBFilterYuvTmp;} 212 217 std::vector<TComDataCU*>& getOneSliceCUDataForNDBFilter (Int sliceID) { return m_vSliceCUDataLink[sliceID];} 218 #endif 213 219 214 220 /* field coding parameters*/ -
trunk/source/Lib/TLibCommon/TComPicSym.cpp
r442 r540 67 67 ,m_puiTileIdxMap(NULL) 68 68 ,m_puiInverseCUOrderMap(NULL) 69 #if HM_CLEANUP_SAO 70 ,m_saoBlkParams(NULL) 71 #endif 69 72 {}; 70 73 … … 127 130 m_puiInverseCUOrderMap[i] = i; 128 131 } 132 133 #if HM_CLEANUP_SAO 134 m_saoBlkParams = new SAOBlkParam[m_uiNumCUsInFrame]; 135 #else 129 136 m_saoParam = NULL; 137 #endif 130 138 } 131 139 … … 183 191 m_puiInverseCUOrderMap = NULL; 184 192 193 #if HM_CLEANUP_SAO 194 if(m_saoBlkParams) 195 { 196 delete[] m_saoBlkParams; m_saoBlkParams = NULL; 197 } 198 #else 185 199 if (m_saoParam) 186 200 { … … 189 203 m_saoParam = NULL; 190 204 } 205 #endif 191 206 } 192 207 … … 332 347 } 333 348 349 350 #if HM_CLEANUP_SAO 351 Void TComPicSym::deriveLoopFilterBoundaryAvailibility(Int ctu, 352 Bool& isLeftAvail, 353 Bool& isRightAvail, 354 Bool& isAboveAvail, 355 Bool& isBelowAvail, 356 Bool& isAboveLeftAvail, 357 Bool& isAboveRightAvail, 358 Bool& isBelowLeftAvail, 359 Bool& isBelowRightAvail 360 ) 361 { 362 363 isLeftAvail = (ctu % m_uiWidthInCU != 0); 364 isRightAvail = (ctu % m_uiWidthInCU != m_uiWidthInCU-1); 365 isAboveAvail = (ctu >= m_uiWidthInCU ); 366 isBelowAvail = (ctu < m_uiNumCUsInFrame - m_uiWidthInCU); 367 isAboveLeftAvail = (isAboveAvail && isLeftAvail); 368 isAboveRightAvail= (isAboveAvail && isRightAvail); 369 isBelowLeftAvail = (isBelowAvail && isLeftAvail); 370 isBelowRightAvail= (isBelowAvail && isRightAvail); 371 372 Bool isLoopFiltAcrossTilePPS = getCU(ctu)->getSlice()->getPPS()->getLoopFilterAcrossTilesEnabledFlag(); 373 374 { 375 TComDataCU* ctuCurr = getCU(ctu); 376 TComDataCU* ctuLeft = isLeftAvail ?getCU(ctu-1):NULL; 377 TComDataCU* ctuRight = isRightAvail?getCU(ctu+1):NULL; 378 TComDataCU* ctuAbove = isAboveAvail?getCU(ctu-m_uiWidthInCU):NULL; 379 TComDataCU* ctuBelow = isBelowAvail?getCU(ctu+m_uiWidthInCU):NULL; 380 TComDataCU* ctuAboveLeft = isAboveLeftAvail ? getCU(ctu-m_uiWidthInCU-1):NULL; 381 TComDataCU* ctuAboveRigtht= isAboveRightAvail? getCU(ctu-m_uiWidthInCU+1):NULL; 382 TComDataCU* ctuBelowLeft = isBelowLeftAvail ? getCU(ctu+m_uiWidthInCU-1):NULL; 383 TComDataCU* ctuBelowRight = isBelowRightAvail? getCU(ctu+m_uiWidthInCU+1):NULL; 384 385 { 386 //left 387 if(ctuLeft != NULL) 388 { 389 isLeftAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuLeft->getSlice()->getSliceCurStartCUAddr())?ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag():true; 390 } 391 //above 392 if(ctuAbove != NULL) 393 { 394 isAboveAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuAbove->getSlice()->getSliceCurStartCUAddr())?ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag():true; 395 } 396 //right 397 if(ctuRight != NULL) 398 { 399 isRightAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuRight->getSlice()->getSliceCurStartCUAddr())?ctuRight->getSlice()->getLFCrossSliceBoundaryFlag():true; 400 } 401 //below 402 if(ctuBelow != NULL) 403 { 404 isBelowAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuBelow->getSlice()->getSliceCurStartCUAddr())?ctuBelow->getSlice()->getLFCrossSliceBoundaryFlag():true; 405 } 406 //above-left 407 if(ctuAboveLeft != NULL) 408 { 409 isAboveLeftAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuAboveLeft->getSlice()->getSliceCurStartCUAddr())?ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag():true; 410 } 411 //below-right 412 if(ctuBelowRight != NULL) 413 { 414 isBelowRightAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuBelowRight->getSlice()->getSliceCurStartCUAddr())?ctuBelowRight->getSlice()->getLFCrossSliceBoundaryFlag():true; 415 } 416 417 418 //above-right 419 if(ctuAboveRigtht != NULL) 420 { 421 Int curSliceStartTS = getCUOrderMap(ctuCurr->getSlice()->getSliceCurStartCUAddr()/m_uiNumPartitions); 422 Int aboveRigthtSliceStartTS = getCUOrderMap(ctuAboveRigtht->getSlice()->getSliceCurStartCUAddr()/m_uiNumPartitions); 423 424 isAboveRightAvail = (curSliceStartTS == aboveRigthtSliceStartTS)?(true): 425 ( 426 (curSliceStartTS > aboveRigthtSliceStartTS)?(ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag()) 427 :(ctuAboveRigtht->getSlice()->getLFCrossSliceBoundaryFlag()) 428 ); 429 } 430 //below-left 431 if(ctuBelowLeft != NULL) 432 { 433 Int curSliceStartTS = getCUOrderMap(ctuCurr->getSlice()->getSliceCurStartCUAddr()/m_uiNumPartitions); 434 Int belowLeftSliceStartTS = getCUOrderMap(ctuBelowLeft->getSlice()->getSliceCurStartCUAddr()/m_uiNumPartitions); 435 436 isBelowLeftAvail = (curSliceStartTS == belowLeftSliceStartTS)?(true): 437 ( 438 (curSliceStartTS > belowLeftSliceStartTS)?(ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag()) 439 :(ctuBelowLeft->getSlice()->getLFCrossSliceBoundaryFlag()) 440 ); 441 } 442 } 443 444 if(!isLoopFiltAcrossTilePPS) 445 { 446 isLeftAvail = (!isLeftAvail ) ?false:(getTileIdxMap( ctuLeft->getAddr() ) == getTileIdxMap( ctu )); 447 isAboveAvail = (!isAboveAvail ) ?false:(getTileIdxMap( ctuAbove->getAddr() ) == getTileIdxMap( ctu )); 448 isRightAvail = (!isRightAvail ) ?false:(getTileIdxMap( ctuRight->getAddr() ) == getTileIdxMap( ctu )); 449 isBelowAvail = (!isBelowAvail ) ?false:(getTileIdxMap( ctuBelow->getAddr() ) == getTileIdxMap( ctu )); 450 isAboveLeftAvail = (!isAboveLeftAvail ) ?false:(getTileIdxMap( ctuAboveLeft->getAddr() ) == getTileIdxMap( ctu )); 451 isAboveRightAvail= (!isAboveRightAvail) ?false:(getTileIdxMap( ctuAboveRigtht->getAddr() ) == getTileIdxMap( ctu )); 452 isBelowLeftAvail = (!isBelowLeftAvail ) ?false:(getTileIdxMap( ctuBelowLeft->getAddr() ) == getTileIdxMap( ctu )); 453 isBelowRightAvail= (!isBelowRightAvail) ?false:(getTileIdxMap( ctuBelowRight->getAddr() ) == getTileIdxMap( ctu )); 454 } 455 } 456 457 } 458 #else 334 459 Void TComPicSym::allocSaoParam(TComSampleAdaptiveOffset *sao) 335 460 { … … 337 462 sao->allocSaoParam(m_saoParam); 338 463 } 464 #endif 339 465 340 466 TComTile::TComTile() -
trunk/source/Lib/TLibCommon/TComPicSym.h
r494 r540 112 112 UInt* m_puiInverseCUOrderMap; 113 113 114 #if HM_CLEANUP_SAO 115 SAOBlkParam *m_saoBlkParams; 116 #else 114 117 SAOParam *m_saoParam; 118 #endif 119 115 120 public: 116 121 Void create ( Int iPicWidth, Int iPicHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth ); … … 171 176 Void xInitTiles(); 172 177 UInt xCalculateNxtCUAddr( UInt uiCurrCUAddr ); 178 #if HM_CLEANUP_SAO 179 SAOBlkParam* getSAOBlkParam() { return m_saoBlkParams;} 180 Void deriveLoopFilterBoundaryAvailibility(Int ctu, Bool& isLeftAvail,Bool& isRightAvail,Bool& isAboveAvail,Bool& isBelowAvail,Bool& isAboveLeftAvail,Bool& isAboveRightAvail,Bool& isBelowLeftAvail,Bool& isBelowRightAvail); 181 #else 173 182 Void allocSaoParam(TComSampleAdaptiveOffset *sao); 174 183 SAOParam *getSaoParam() { return m_saoParam; } 184 #endif 185 186 175 187 };// END CLASS DEFINITION TComPicSym 176 188 -
trunk/source/Lib/TLibCommon/TComRdCost.cpp
r494 r540 330 330 331 331 // Setting the Distortion Parameter for Inter (subpel ME with step) 332 #if NS_HAD333 Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME, Bool bUseNSHAD )334 #else335 332 Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME ) 336 #endif337 333 { 338 334 #if O0194_WEIGHTED_PREDICTION_CGS … … 353 349 rcDistParam.iCols = pcPatternKey->getROIYWidth(); 354 350 rcDistParam.iRows = pcPatternKey->getROIYHeight(); 355 #if NS_HAD356 rcDistParam.bUseNSHAD = bUseNSHAD;357 #endif358 351 359 352 // set distortion function … … 386 379 387 380 Void 388 #if NS_HAD389 TComRdCost::setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard, Bool bUseNSHAD )390 #else391 381 TComRdCost::setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard ) 392 #endif393 382 { 394 383 rcDP.pOrg = p1; … … 402 391 rcDP.bitDepth = bitDepth; 403 392 rcDP.DistFunc = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ]; 404 #if NS_HAD405 rcDP.bUseNSHAD = bUseNSHAD;406 #endif407 393 } 408 394 … … 453 439 } 454 440 455 #if WEIGHTED_CHROMA_DISTORTION456 441 UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText, DFunc eDFunc) 457 #else458 UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc )459 #endif460 442 { 461 443 DistParam cDtParam; … … 471 453 cDtParam.bitDepth = bitDepth; 472 454 473 #if WEIGHTED_CHROMA_DISTORTION474 455 if (eText == TEXT_CHROMA_U) 475 456 { … … 484 465 return cDtParam.DistFunc( &cDtParam ); 485 466 } 486 #else 487 return cDtParam.DistFunc( &cDtParam ); 488 #endif 489 } 490 491 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT 492 UInt TComRdCost::getSADPart ( Int bitDepth, Pel* pelCur, Int curStride, Pel* pelOrg, Int orgStride, UInt width, UInt height ) 493 { 494 UInt SAD = 0; 495 Int shift = DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8); 496 for ( Int i=0; i<height; i++ ) 497 { 498 for( Int j=0; j<width; j++ ) 499 { 500 SAD += abs((pelCur[j] - pelOrg[j])) >> shift; 501 } 502 pelCur = pelCur + curStride; 503 pelOrg = pelOrg + orgStride; 504 } 505 return SAD; 506 } 507 #endif 467 } 508 468 509 469 // ==================================================================================================================== … … 1579 1539 } 1580 1540 1581 #if NS_HAD1582 UInt TComRdCost::xCalcHADs16x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )1583 {1584 Int k, i, j, jj, sad=0;1585 Int diff[64], m1[4][16], m2[4][16];1586 assert( iStep == 1 );1587 for( k = 0; k < 64; k += 16 )1588 {1589 diff[k+0] = piOrg[0] - piCur[0];1590 diff[k+1] = piOrg[1] - piCur[1];1591 diff[k+2] = piOrg[2] - piCur[2];1592 diff[k+3] = piOrg[3] - piCur[3];1593 diff[k+4] = piOrg[4] - piCur[4];1594 diff[k+5] = piOrg[5] - piCur[5];1595 diff[k+6] = piOrg[6] - piCur[6];1596 diff[k+7] = piOrg[7] - piCur[7];1597 1598 diff[k+8] = piOrg[8] - piCur[8] ;1599 diff[k+9] = piOrg[9] - piCur[9] ;1600 diff[k+10] = piOrg[10] - piCur[10];1601 diff[k+11] = piOrg[11] - piCur[11];1602 diff[k+12] = piOrg[12] - piCur[12];1603 diff[k+13] = piOrg[13] - piCur[13];1604 diff[k+14] = piOrg[14] - piCur[14];1605 diff[k+15] = piOrg[15] - piCur[15];1606 1607 piCur += iStrideCur;1608 piOrg += iStrideOrg;1609 }1610 1611 //horizontal1612 for (j=0; j < 4; j++)1613 {1614 jj = j << 4;1615 1616 m2[j][0] = diff[jj ] + diff[jj+8];1617 m2[j][1] = diff[jj+1] + diff[jj+9];1618 m2[j][2] = diff[jj+2] + diff[jj+10];1619 m2[j][3] = diff[jj+3] + diff[jj+11];1620 m2[j][4] = diff[jj+4] + diff[jj+12];1621 m2[j][5] = diff[jj+5] + diff[jj+13];1622 m2[j][6] = diff[jj+6] + diff[jj+14];1623 m2[j][7] = diff[jj+7] + diff[jj+15];1624 m2[j][8] = diff[jj ] - diff[jj+8];1625 m2[j][9] = diff[jj+1] - diff[jj+9];1626 m2[j][10] = diff[jj+2] - diff[jj+10];1627 m2[j][11] = diff[jj+3] - diff[jj+11];1628 m2[j][12] = diff[jj+4] - diff[jj+12];1629 m2[j][13] = diff[jj+5] - diff[jj+13];1630 m2[j][14] = diff[jj+6] - diff[jj+14];1631 m2[j][15] = diff[jj+7] - diff[jj+15];1632 1633 m1[j][0] = m2[j][0] + m2[j][4];1634 m1[j][1] = m2[j][1] + m2[j][5];1635 m1[j][2] = m2[j][2] + m2[j][6];1636 m1[j][3] = m2[j][3] + m2[j][7];1637 m1[j][4] = m2[j][0] - m2[j][4];1638 m1[j][5] = m2[j][1] - m2[j][5];1639 m1[j][6] = m2[j][2] - m2[j][6];1640 m1[j][7] = m2[j][3] - m2[j][7];1641 m1[j][8] = m2[j][8] + m2[j][12];1642 m1[j][9] = m2[j][9] + m2[j][13];1643 m1[j][10] = m2[j][10] + m2[j][14];1644 m1[j][11] = m2[j][11] + m2[j][15];1645 m1[j][12] = m2[j][8] - m2[j][12];1646 m1[j][13] = m2[j][9] - m2[j][13];1647 m1[j][14] = m2[j][10] - m2[j][14];1648 m1[j][15] = m2[j][11] - m2[j][15];1649 1650 m2[j][0] = m1[j][0] + m1[j][2];1651 m2[j][1] = m1[j][1] + m1[j][3];1652 m2[j][2] = m1[j][0] - m1[j][2];1653 m2[j][3] = m1[j][1] - m1[j][3];1654 m2[j][4] = m1[j][4] + m1[j][6];1655 m2[j][5] = m1[j][5] + m1[j][7];1656 m2[j][6] = m1[j][4] - m1[j][6];1657 m2[j][7] = m1[j][5] - m1[j][7];1658 m2[j][8] = m1[j][8] + m1[j][10];1659 m2[j][9] = m1[j][9] + m1[j][11];1660 m2[j][10] = m1[j][8] - m1[j][10];1661 m2[j][11] = m1[j][9] - m1[j][11];1662 m2[j][12] = m1[j][12] + m1[j][14];1663 m2[j][13] = m1[j][13] + m1[j][15];1664 m2[j][14] = m1[j][12] - m1[j][14];1665 m2[j][15] = m1[j][13] - m1[j][15];1666 1667 m1[j][0] = m2[j][0] + m2[j][1];1668 m1[j][1] = m2[j][0] - m2[j][1];1669 m1[j][2] = m2[j][2] + m2[j][3];1670 m1[j][3] = m2[j][2] - m2[j][3];1671 m1[j][4] = m2[j][4] + m2[j][5];1672 m1[j][5] = m2[j][4] - m2[j][5];1673 m1[j][6] = m2[j][6] + m2[j][7];1674 m1[j][7] = m2[j][6] - m2[j][7];1675 m1[j][8] = m2[j][8] + m2[j][9];1676 m1[j][9] = m2[j][8] - m2[j][9];1677 m1[j][10] = m2[j][10] + m2[j][11];1678 m1[j][11] = m2[j][10] - m2[j][11];1679 m1[j][12] = m2[j][12] + m2[j][13];1680 m1[j][13] = m2[j][12] - m2[j][13];1681 m1[j][14] = m2[j][14] + m2[j][15];1682 m1[j][15] = m2[j][14] - m2[j][15];1683 }1684 1685 //vertical1686 for (i=0; i < 16; i++)1687 {1688 m2[0][i] = m1[0][i] + m1[2][i];1689 m2[1][i] = m1[1][i] + m1[3][i];1690 m2[2][i] = m1[0][i] - m1[2][i];1691 m2[3][i] = m1[1][i] - m1[3][i];1692 1693 m1[0][i] = m2[0][i] + m2[1][i];1694 m1[1][i] = m2[0][i] - m2[1][i];1695 m1[2][i] = m2[2][i] + m2[3][i];1696 m1[3][i] = m2[2][i] - m2[3][i];1697 }1698 1699 for (i = 0; i < 4; i++)1700 {1701 for (j = 0; j < 16; j++)1702 {1703 sad += abs(m1[i][j]);1704 }1705 }1706 1707 sad=((sad+2)>>2);1708 1709 return sad;1710 }1711 1712 UInt TComRdCost::xCalcHADs4x16( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )1713 {1714 Int k, i, j, jj, sad=0;1715 Int diff[64], m1[16][4], m2[16][4], m3[16][4];1716 assert( iStep == 1 );1717 for( k = 0; k < 64; k += 4 )1718 {1719 diff[k+0] = piOrg[0] - piCur[0];1720 diff[k+1] = piOrg[1] - piCur[1];1721 diff[k+2] = piOrg[2] - piCur[2];1722 diff[k+3] = piOrg[3] - piCur[3];1723 1724 piCur += iStrideCur;1725 piOrg += iStrideOrg;1726 }1727 1728 //horizontal1729 for (j=0; j < 16; j++)1730 {1731 jj = j << 2;1732 m2[j][0] = diff[jj ] + diff[jj+2];1733 m2[j][1] = diff[jj+1] + diff[jj+3];1734 m2[j][2] = diff[jj ] - diff[jj+2];1735 m2[j][3] = diff[jj+1] - diff[jj+3];1736 1737 m1[j][0] = m2[j][0] + m2[j][1];1738 m1[j][1] = m2[j][0] - m2[j][1];1739 m1[j][2] = m2[j][2] + m2[j][3];1740 m1[j][3] = m2[j][2] - m2[j][3];1741 }1742 1743 //vertical1744 for (i=0; i < 4; i++)1745 {1746 m2[0][i] = m1[0][i] + m1[8][i];1747 m2[1][i] = m1[1][i] + m1[9][i];1748 m2[2][i] = m1[2][i] + m1[10][i];1749 m2[3][i] = m1[3][i] + m1[11][i];1750 m2[4][i] = m1[4][i] + m1[12][i];1751 m2[5][i] = m1[5][i] + m1[13][i];1752 m2[6][i] = m1[6][i] + m1[14][i];1753 m2[7][i] = m1[7][i] + m1[15][i];1754 m2[8][i] = m1[0][i] - m1[8][i];1755 m2[9][i] = m1[1][i] - m1[9][i];1756 m2[10][i] = m1[2][i] - m1[10][i];1757 m2[11][i] = m1[3][i] - m1[11][i];1758 m2[12][i] = m1[4][i] - m1[12][i];1759 m2[13][i] = m1[5][i] - m1[13][i];1760 m2[14][i] = m1[6][i] - m1[14][i];1761 m2[15][i] = m1[7][i] - m1[15][i];1762 1763 m3[0][i] = m2[0][i] + m2[4][i];1764 m3[1][i] = m2[1][i] + m2[5][i];1765 m3[2][i] = m2[2][i] + m2[6][i];1766 m3[3][i] = m2[3][i] + m2[7][i];1767 m3[4][i] = m2[0][i] - m2[4][i];1768 m3[5][i] = m2[1][i] - m2[5][i];1769 m3[6][i] = m2[2][i] - m2[6][i];1770 m3[7][i] = m2[3][i] - m2[7][i];1771 m3[8][i] = m2[8][i] + m2[12][i];1772 m3[9][i] = m2[9][i] + m2[13][i];1773 m3[10][i] = m2[10][i] + m2[14][i];1774 m3[11][i] = m2[11][i] + m2[15][i];1775 m3[12][i] = m2[8][i] - m2[12][i];1776 m3[13][i] = m2[9][i] - m2[13][i];1777 m3[14][i] = m2[10][i] - m2[14][i];1778 m3[15][i] = m2[11][i] - m2[15][i];1779 1780 m1[0][i] = m3[0][i] + m3[2][i];1781 m1[1][i] = m3[1][i] + m3[3][i];1782 m1[2][i] = m3[0][i] - m3[2][i];1783 m1[3][i] = m3[1][i] - m3[3][i];1784 m1[4][i] = m3[4][i] + m3[6][i];1785 m1[5][i] = m3[5][i] + m3[7][i];1786 m1[6][i] = m3[4][i] - m3[6][i];1787 m1[7][i] = m3[5][i] - m3[7][i];1788 m1[8][i] = m3[8][i] + m3[10][i];1789 m1[9][i] = m3[9][i] + m3[11][i];1790 m1[10][i] = m3[8][i] - m3[10][i];1791 m1[11][i] = m3[9][i] - m3[11][i];1792 m1[12][i] = m3[12][i] + m3[14][i];1793 m1[13][i] = m3[13][i] + m3[15][i];1794 m1[14][i] = m3[12][i] - m3[14][i];1795 m1[15][i] = m3[13][i] - m3[15][i];1796 1797 m2[0][i] = m1[0][i] + m1[1][i];1798 m2[1][i] = m1[0][i] - m1[1][i];1799 m2[2][i] = m1[2][i] + m1[3][i];1800 m2[3][i] = m1[2][i] - m1[3][i];1801 m2[4][i] = m1[4][i] + m1[5][i];1802 m2[5][i] = m1[4][i] - m1[5][i];1803 m2[6][i] = m1[6][i] + m1[7][i];1804 m2[7][i] = m1[6][i] - m1[7][i];1805 m2[8][i] = m1[8][i] + m1[9][i];1806 m2[9][i] = m1[8][i] - m1[9][i];1807 m2[10][i] = m1[10][i] + m1[11][i];1808 m2[11][i] = m1[10][i] - m1[11][i];1809 m2[12][i] = m1[12][i] + m1[13][i];1810 m2[13][i] = m1[12][i] - m1[13][i];1811 m2[14][i] = m1[14][i] + m1[15][i];1812 m2[15][i] = m1[14][i] - m1[15][i];1813 }1814 1815 for (i = 0; i < 16; i++)1816 {1817 for (j = 0; j < 4; j++)1818 {1819 sad += abs(m2[i][j]);1820 }1821 }1822 1823 sad=((sad+2)>>2);1824 1825 return sad;1826 }1827 #endif1828 1829 1541 UInt TComRdCost::xGetHADs4( DistParam* pcDtParam ) 1830 1542 { … … 1909 1621 UInt uiSum = 0; 1910 1622 1911 #if NS_HAD1912 if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) )1913 #else1914 1623 if( ( iRows % 8 == 0) && (iCols % 8 == 0) ) 1915 #endif1916 1624 { 1917 1625 Int iOffsetOrg = iStrideOrg<<3; … … 1927 1635 } 1928 1636 } 1929 #if NS_HAD1930 else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD )1931 {1932 Int iOffsetOrg = iStrideOrg<<2;1933 Int iOffsetCur = iStrideCur<<2;1934 for ( y=0; y<iRows; y+= 4 )1935 {1936 for ( x=0; x<iCols; x+= 16 )1937 {1938 uiSum += xCalcHADs16x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );1939 }1940 piOrg += iOffsetOrg;1941 piCur += iOffsetCur;1942 }1943 }1944 else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD )1945 {1946 Int iOffsetOrg = iStrideOrg<<4;1947 Int iOffsetCur = iStrideCur<<4;1948 for ( y=0; y<iRows; y+= 16 )1949 {1950 for ( x=0; x<iCols; x+= 4 )1951 {1952 uiSum += xCalcHADs4x16( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );1953 }1954 piOrg += iOffsetOrg;1955 piCur += iOffsetCur;1956 }1957 }1958 #endif1959 1637 else if( ( iRows % 4 == 0) && (iCols % 4 == 0) ) 1960 1638 { -
trunk/source/Lib/TLibCommon/TComRdCost.h
r442 r540 84 84 UInt uiComp; // uiComp = 0 (luma Y), 1 (chroma U), 2 (chroma V) 85 85 86 #if NS_HAD87 Bool bUseNSHAD;88 #endif89 90 86 // (vertical) subsampling shift (for reducing complexity) 91 87 // - 0 = no subsampling, 1 = even rows, 2 = every 4th, etc. … … 104 100 iSubShift = 0; 105 101 bitDepth = 0; 106 #if NS_HAD107 bUseNSHAD = false;108 #endif109 102 } 110 103 }; … … 123 116 #endif 124 117 125 #if WEIGHTED_CHROMA_DISTORTION126 118 Double m_cbDistortionWeight; 127 119 Double m_crDistortionWeight; 128 #endif129 120 Double m_dLambda; 130 121 Double m_sqrtLambda; … … 155 146 Double calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT ); 156 147 157 #if WEIGHTED_CHROMA_DISTORTION158 148 Void setCbDistortionWeight ( Double cbDistortionWeight) { m_cbDistortionWeight = cbDistortionWeight; }; 159 149 Void setCrDistortionWeight ( Double crDistortionWeight) { m_crDistortionWeight = crDistortionWeight; }; 160 #endif161 150 Void setLambda ( Double dLambda ); 162 151 Void setFrameLambda ( Double dLambda ) { m_dFrameLambda = dLambda; } … … 164 153 Double getSqrtLambda () { return m_sqrtLambda; } 165 154 166 #if RATE_CONTROL_LAMBDA_DOMAIN167 155 Double getLambda() { return m_dLambda; } 168 #if M0036_RC_IMPROVEMENT169 156 Double getChromaWeight () {return((m_cbDistortionWeight+m_crDistortionWeight)/2.0);} 170 #endif171 #endif172 157 173 158 // Distortion Functions … … 176 161 Void setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc, DistParam& rcDistParam ); 177 162 Void setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, DistParam& rcDistParam ); 178 #if NS_HAD179 Void setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false, Bool bUseNSHAD=false );180 Void setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false, Bool bUseNSHAD=false );181 #else182 163 Void setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false ); 183 164 Void setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false ); 184 #endif185 165 186 166 UInt calcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight ); … … 253 233 static UInt xCalcHADs4x4 ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep ); 254 234 static UInt xCalcHADs8x8 ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep ); 255 #if NS_HAD256 static UInt xCalcHADs16x4 ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );257 static UInt xCalcHADs4x16 ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );258 #endif259 235 260 236 public: 261 #if WEIGHTED_CHROMA_DISTORTION262 237 UInt getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText = TEXT_LUMA, DFunc eDFunc = DF_SSE ); 263 #else 264 UInt getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc = DF_SSE ); 265 #endif 266 267 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT 268 UInt getSADPart ( Int bitDepth, Pel* pelCur, Int curStride, Pel* pelOrg, Int orgStride, UInt width, UInt height ); 269 #endif 238 270 239 };// END CLASS DEFINITION TComRdCost 271 240 -
trunk/source/Lib/TLibCommon/TComRom.cpp
r494 r540 363 363 const UInt g_uiGroupIdx[ 32 ] = {0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9}; 364 364 365 // Rice parameters for absolute transform levels366 const UInt g_auiGoRiceRange[5] =367 {368 7, 14, 26, 46, 78369 };370 371 const UInt g_auiGoRicePrefixLen[5] =372 {373 8, 7, 6, 5, 4374 };375 376 365 Void initSigLastScan(UInt* pBuffD, UInt* pBuffH, UInt* pBuffV, Int iWidth, Int iHeight) 377 366 { … … 541 530 Int g_mvScalingFactor [MAX_LAYERS][2] = {{0,0}, {0,0}}; 542 531 Int g_posScalingFactor [MAX_LAYERS][2] = {{0,0}, {0,0}}; 543 544 #if IL_SL_SIGNALLING_N0371545 Int ref_scalingListDC [MAX_LAYERS][SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM];546 Int ref_scalingListCoef [MAX_LAYERS][SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM][MAX_MATRIX_COEF_NUM];547 Int activeRefPPSId [MAX_LAYERS];548 Int activeRefSPSId [MAX_LAYERS];549 #endif550 532 #endif 551 533 -
trunk/source/Lib/TLibCommon/TComRom.h
r494 r540 131 131 extern const UInt g_uiMinInGroup[ 10 ]; 132 132 133 extern const UInt g_auiGoRiceRange[5]; //!< maximum value coded with Rice codes134 extern const UInt g_auiGoRicePrefixLen[5]; //!< prefix length for each maximum value135 136 133 extern const UInt g_sigLastScan8x8[ 3 ][ 4 ]; //!< coefficient group scan order for 8x8 TUs 137 134 extern UInt g_sigLastScanCG32x32[ 64 ]; … … 291 288 #if SVC_EXTENSION 292 289 extern Int g_mvScalingFactor [MAX_LAYERS][2]; 293 extern Int g_posScalingFactor [MAX_LAYERS][2]; 294 295 #if IL_SL_SIGNALLING_N0371 296 extern Int ref_scalingListDC [MAX_LAYERS][SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; 297 extern Int ref_scalingListCoef [MAX_LAYERS][SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM][MAX_MATRIX_COEF_NUM]; 298 extern Int activeRefPPSId [MAX_LAYERS]; 299 extern Int activeRefSPSId [MAX_LAYERS]; 300 #endif 290 extern Int g_posScalingFactor [MAX_LAYERS][2]; 301 291 #endif 302 292 -
trunk/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp
r442 r540 44 44 //! \ingroup TLibCommon 45 45 //! \{ 46 #if HM_CLEANUP_SAO 47 UInt g_saoMaxOffsetQVal[NUM_SAO_COMPONENTS]; 48 49 SAOOffset::SAOOffset() 50 { 51 reset(); 52 } 53 54 SAOOffset::~SAOOffset() 55 { 56 57 } 58 59 Void SAOOffset::reset() 60 { 61 modeIdc = SAO_MODE_OFF; 62 typeIdc = -1; 63 typeAuxInfo = -1; 64 ::memset(offset, 0, sizeof(Int)* MAX_NUM_SAO_CLASSES); 65 } 66 67 const SAOOffset& SAOOffset::operator= (const SAOOffset& src) 68 { 69 modeIdc = src.modeIdc; 70 typeIdc = src.typeIdc; 71 typeAuxInfo = src.typeAuxInfo; 72 ::memcpy(offset, src.offset, sizeof(Int)* MAX_NUM_SAO_CLASSES); 73 74 return *this; 75 } 76 77 78 SAOBlkParam::SAOBlkParam() 79 { 80 reset(); 81 } 82 83 SAOBlkParam::~SAOBlkParam() 84 { 85 86 } 87 88 Void SAOBlkParam::reset() 89 { 90 for(Int compIdx=0; compIdx< 3; compIdx++) 91 { 92 offsetParam[compIdx].reset(); 93 } 94 } 95 96 const SAOBlkParam& SAOBlkParam::operator= (const SAOBlkParam& src) 97 { 98 for(Int compIdx=0; compIdx< 3; compIdx++) 99 { 100 offsetParam[compIdx] = src.offsetParam[compIdx]; 101 } 102 return *this; 103 104 } 105 106 TComSampleAdaptiveOffset::TComSampleAdaptiveOffset() 107 { 108 m_tempPicYuv = NULL; 109 for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++) 110 { 111 m_offsetClipTable[compIdx] = NULL; 112 } 113 m_signTable = NULL; 114 115 116 m_lineBufWidth = 0; 117 m_signLineBuf1 = NULL; 118 m_signLineBuf2 = NULL; 119 } 120 121 122 TComSampleAdaptiveOffset::~TComSampleAdaptiveOffset() 123 { 124 destroy(); 125 126 if (m_signLineBuf1) delete[] m_signLineBuf1; m_signLineBuf1 = NULL; 127 if (m_signLineBuf2) delete[] m_signLineBuf2; m_signLineBuf2 = NULL; 128 } 129 130 #if AUXILIARY_PICTURES 131 Void TComSampleAdaptiveOffset::create( Int picWidth, Int picHeight, ChromaFormat chromaFormatIDC, UInt maxCUWidth, UInt maxCUHeight, UInt maxCUDepth ) 132 #else 133 Void TComSampleAdaptiveOffset::create( Int picWidth, Int picHeight, UInt maxCUWidth, UInt maxCUHeight, UInt maxCUDepth ) 134 #endif 135 { 136 destroy(); 137 138 m_picWidth = picWidth; 139 m_picHeight= picHeight; 140 m_maxCUWidth= maxCUWidth; 141 m_maxCUHeight= maxCUHeight; 142 143 m_numCTUInWidth = (m_picWidth/m_maxCUWidth) + ((m_picWidth % m_maxCUWidth)?1:0); 144 m_numCTUInHeight= (m_picHeight/m_maxCUHeight) + ((m_picHeight % m_maxCUHeight)?1:0); 145 m_numCTUsPic = m_numCTUInHeight*m_numCTUInWidth; 146 147 //temporary picture buffer 148 if ( !m_tempPicYuv ) 149 { 150 m_tempPicYuv = new TComPicYuv; 151 #if AUXILIARY_PICTURES 152 m_tempPicYuv->create( m_picWidth, m_picHeight, chromaFormatIDC, m_maxCUWidth, m_maxCUHeight, maxCUDepth ); 153 #else 154 m_tempPicYuv->create( m_picWidth, m_picHeight, m_maxCUWidth, m_maxCUHeight, maxCUDepth ); 155 #endif 156 } 157 158 //bit-depth related 159 for(Int compIdx =0; compIdx < NUM_SAO_COMPONENTS; compIdx++) 160 { 161 Int bitDepthSample = (compIdx == SAO_Y)?g_bitDepthY:g_bitDepthC; 162 m_offsetStepLog2 [compIdx] = max(bitDepthSample - MAX_SAO_TRUNCATED_BITDEPTH, 0); 163 g_saoMaxOffsetQVal[compIdx] = (1<<(min(bitDepthSample,MAX_SAO_TRUNCATED_BITDEPTH)-5))-1; //Table 9-32, inclusive 164 } 165 166 //look-up table for clipping 167 for(Int compIdx =0; compIdx < NUM_SAO_COMPONENTS; compIdx++) 168 { 169 Int bitDepthSample = (compIdx == SAO_Y)?g_bitDepthY:g_bitDepthC; //exclusive 170 Int maxSampleValue = (1<< bitDepthSample); //exclusive 171 Int maxOffsetValue = (g_saoMaxOffsetQVal[compIdx] << m_offsetStepLog2[compIdx]); 172 173 m_offsetClipTable[compIdx] = new Int[(maxSampleValue + maxOffsetValue -1)+ (maxOffsetValue)+1 ]; //positive & negative range plus 0 174 m_offsetClip[compIdx] = &(m_offsetClipTable[compIdx][maxOffsetValue]); 175 176 //assign clipped values 177 Int* offsetClipPtr = m_offsetClip[compIdx]; 178 for(Int k=0; k< maxSampleValue; k++) 179 { 180 *(offsetClipPtr + k) = k; 181 } 182 for(Int k=0; k< maxOffsetValue; k++ ) 183 { 184 *(offsetClipPtr + maxSampleValue+ k) = maxSampleValue-1; 185 *(offsetClipPtr -k -1 ) = 0; 186 } 187 if(compIdx == SAO_Y) //g_bitDepthY is always larger than or equal to g_bitDepthC 188 { 189 m_signTable = new Short[ 2*(maxSampleValue-1) + 1 ]; 190 m_sign = &(m_signTable[maxSampleValue-1]); 191 192 m_sign[0] = 0; 193 for(Int k=1; k< maxSampleValue; k++) 194 { 195 m_sign[k] = 1; 196 m_sign[-k]= -1; 197 } 198 } 199 } 200 201 } 202 203 Void TComSampleAdaptiveOffset::destroy() 204 { 205 if ( m_tempPicYuv ) 206 { 207 m_tempPicYuv->destroy(); 208 delete m_tempPicYuv; 209 m_tempPicYuv = NULL; 210 } 211 212 for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++) 213 { 214 if(m_offsetClipTable[compIdx]) 215 { 216 delete[] m_offsetClipTable[compIdx]; m_offsetClipTable[compIdx] = NULL; 217 } 218 } 219 if( m_signTable ) 220 { 221 delete[] m_signTable; m_signTable = NULL; 222 } 223 } 224 225 Void TComSampleAdaptiveOffset::invertQuantOffsets(Int compIdx, Int typeIdc, Int typeAuxInfo, Int* dstOffsets, Int* srcOffsets) 226 { 227 Int codedOffset[MAX_NUM_SAO_CLASSES]; 228 229 ::memcpy(codedOffset, srcOffsets, sizeof(Int)*MAX_NUM_SAO_CLASSES); 230 ::memset(dstOffsets, 0, sizeof(Int)*MAX_NUM_SAO_CLASSES); 231 232 if(typeIdc == SAO_TYPE_START_BO) 233 { 234 for(Int i=0; i< 4; i++) 235 { 236 dstOffsets[(typeAuxInfo+ i)%NUM_SAO_BO_CLASSES] = codedOffset[(typeAuxInfo+ i)%NUM_SAO_BO_CLASSES]*(1<<m_offsetStepLog2[compIdx]); 237 } 238 } 239 else //EO 240 { 241 for(Int i=0; i< NUM_SAO_EO_CLASSES; i++) 242 { 243 dstOffsets[i] = codedOffset[i] *(1<<m_offsetStepLog2[compIdx]); 244 } 245 assert(dstOffsets[SAO_CLASS_EO_PLAIN] == 0); //keep EO plain offset as zero 246 } 247 248 } 249 250 Int TComSampleAdaptiveOffset::getMergeList(TComPic* pic, Int ctu, SAOBlkParam* blkParams, std::vector<SAOBlkParam*>& mergeList) 251 { 252 Int ctuX = ctu % m_numCTUInWidth; 253 Int ctuY = ctu / m_numCTUInWidth; 254 Int mergedCTUPos; 255 Int numValidMergeCandidates = 0; 256 257 for(Int mergeType=0; mergeType< NUM_SAO_MERGE_TYPES; mergeType++) 258 { 259 SAOBlkParam* mergeCandidate = NULL; 260 261 switch(mergeType) 262 { 263 case SAO_MERGE_ABOVE: 264 { 265 if(ctuY > 0) 266 { 267 mergedCTUPos = ctu- m_numCTUInWidth; 268 if( pic->getSAOMergeAvailability(ctu, mergedCTUPos) ) 269 { 270 mergeCandidate = &(blkParams[mergedCTUPos]); 271 } 272 } 273 } 274 break; 275 case SAO_MERGE_LEFT: 276 { 277 if(ctuX > 0) 278 { 279 mergedCTUPos = ctu- 1; 280 if( pic->getSAOMergeAvailability(ctu, mergedCTUPos) ) 281 { 282 mergeCandidate = &(blkParams[mergedCTUPos]); 283 } 284 } 285 } 286 break; 287 default: 288 { 289 printf("not a supported merge type"); 290 assert(0); 291 exit(-1); 292 } 293 } 294 295 mergeList.push_back(mergeCandidate); 296 if (mergeCandidate != NULL) 297 { 298 numValidMergeCandidates++; 299 } 300 } 301 302 return numValidMergeCandidates; 303 } 304 305 306 Void TComSampleAdaptiveOffset::reconstructBlkSAOParam(SAOBlkParam& recParam, std::vector<SAOBlkParam*>& mergeList) 307 { 308 for(Int compIdx=0; compIdx< NUM_SAO_COMPONENTS; compIdx++) 309 { 310 SAOOffset& offsetParam = recParam[compIdx]; 311 312 if(offsetParam.modeIdc == SAO_MODE_OFF) 313 { 314 continue; 315 } 316 317 switch(offsetParam.modeIdc) 318 { 319 case SAO_MODE_NEW: 320 { 321 invertQuantOffsets(compIdx, offsetParam.typeIdc, offsetParam.typeAuxInfo, offsetParam.offset, offsetParam.offset); 322 } 323 break; 324 case SAO_MODE_MERGE: 325 { 326 SAOBlkParam* mergeTarget = mergeList[offsetParam.typeIdc]; 327 assert(mergeTarget != NULL); 328 329 offsetParam = (*mergeTarget)[compIdx]; 330 } 331 break; 332 default: 333 { 334 printf("Not a supported mode"); 335 assert(0); 336 exit(-1); 337 } 338 } 339 } 340 } 341 342 Void TComSampleAdaptiveOffset::reconstructBlkSAOParams(TComPic* pic, SAOBlkParam* saoBlkParams) 343 { 344 m_picSAOEnabled[SAO_Y] = m_picSAOEnabled[SAO_Cb] = m_picSAOEnabled[SAO_Cr] = false; 345 346 for(Int ctu=0; ctu< m_numCTUsPic; ctu++) 347 { 348 std::vector<SAOBlkParam*> mergeList; 349 getMergeList(pic, ctu, saoBlkParams, mergeList); 350 351 reconstructBlkSAOParam(saoBlkParams[ctu], mergeList); 352 353 for(Int compIdx=0; compIdx< NUM_SAO_COMPONENTS; compIdx++) 354 { 355 if(saoBlkParams[ctu][compIdx].modeIdc != SAO_MODE_OFF) 356 { 357 m_picSAOEnabled[compIdx] = true; 358 } 359 } 360 } 361 362 363 } 364 365 366 Void TComSampleAdaptiveOffset::offsetBlock(Int compIdx, Int typeIdx, Int* offset 367 , Pel* srcBlk, Pel* resBlk, Int srcStride, Int resStride, Int width, Int height 368 , Bool isLeftAvail, Bool isRightAvail, Bool isAboveAvail, Bool isBelowAvail, Bool isAboveLeftAvail, Bool isAboveRightAvail, Bool isBelowLeftAvail, Bool isBelowRightAvail) 369 { 370 if(m_lineBufWidth != m_maxCUWidth) 371 { 372 m_lineBufWidth = m_maxCUWidth; 373 374 if (m_signLineBuf1) delete[] m_signLineBuf1; m_signLineBuf1 = NULL; 375 m_signLineBuf1 = new Char[m_lineBufWidth+1]; 376 377 if (m_signLineBuf2) delete[] m_signLineBuf2; m_signLineBuf2 = NULL; 378 m_signLineBuf2 = new Char[m_lineBufWidth+1]; 379 } 380 381 Int* offsetClip = m_offsetClip[compIdx]; 382 383 Int x,y, startX, startY, endX, endY, edgeType; 384 Int firstLineStartX, firstLineEndX, lastLineStartX, lastLineEndX; 385 Char signLeft, signRight, signDown; 386 387 Pel* srcLine = srcBlk; 388 Pel* resLine = resBlk; 389 390 switch(typeIdx) 391 { 392 case SAO_TYPE_EO_0: 393 { 394 offset += 2; 395 startX = isLeftAvail ? 0 : 1; 396 endX = isRightAvail ? width : (width -1); 397 for (y=0; y< height; y++) 398 { 399 signLeft = (Char)m_sign[srcLine[startX] - srcLine[startX-1]]; 400 for (x=startX; x< endX; x++) 401 { 402 signRight = (Char)m_sign[srcLine[x] - srcLine[x+1]]; 403 edgeType = signRight + signLeft; 404 signLeft = -signRight; 405 406 resLine[x] = offsetClip[srcLine[x] + offset[edgeType]]; 407 } 408 srcLine += srcStride; 409 resLine += resStride; 410 } 411 412 } 413 break; 414 case SAO_TYPE_EO_90: 415 { 416 offset += 2; 417 Char *signUpLine = m_signLineBuf1; 418 419 startY = isAboveAvail ? 0 : 1; 420 endY = isBelowAvail ? height : height-1; 421 if (!isAboveAvail) 422 { 423 srcLine += srcStride; 424 resLine += resStride; 425 } 426 427 Pel* srcLineAbove= srcLine- srcStride; 428 for (x=0; x< width; x++) 429 { 430 signUpLine[x] = (Char)m_sign[srcLine[x] - srcLineAbove[x]]; 431 } 432 433 Pel* srcLineBelow; 434 for (y=startY; y<endY; y++) 435 { 436 srcLineBelow= srcLine+ srcStride; 437 438 for (x=0; x< width; x++) 439 { 440 signDown = (Char)m_sign[srcLine[x] - srcLineBelow[x]]; 441 edgeType = signDown + signUpLine[x]; 442 signUpLine[x]= -signDown; 443 444 resLine[x] = offsetClip[srcLine[x] + offset[edgeType]]; 445 } 446 srcLine += srcStride; 447 resLine += resStride; 448 } 449 450 } 451 break; 452 case SAO_TYPE_EO_135: 453 { 454 offset += 2; 455 Char *signUpLine, *signDownLine, *signTmpLine; 456 457 signUpLine = m_signLineBuf1; 458 signDownLine= m_signLineBuf2; 459 460 startX = isLeftAvail ? 0 : 1 ; 461 endX = isRightAvail ? width : (width-1); 462 463 //prepare 2nd line's upper sign 464 Pel* srcLineBelow= srcLine+ srcStride; 465 for (x=startX; x< endX+1; x++) 466 { 467 signUpLine[x] = (Char)m_sign[srcLineBelow[x] - srcLine[x- 1]]; 468 } 469 470 //1st line 471 Pel* srcLineAbove= srcLine- srcStride; 472 firstLineStartX = isAboveLeftAvail ? 0 : 1; 473 firstLineEndX = isAboveAvail? endX: 1; 474 for(x= firstLineStartX; x< firstLineEndX; x++) 475 { 476 edgeType = m_sign[srcLine[x] - srcLineAbove[x- 1]] - signUpLine[x+1]; 477 resLine[x] = offsetClip[srcLine[x] + offset[edgeType]]; 478 } 479 srcLine += srcStride; 480 resLine += resStride; 481 482 483 //middle lines 484 for (y= 1; y< height-1; y++) 485 { 486 srcLineBelow= srcLine+ srcStride; 487 488 for (x=startX; x<endX; x++) 489 { 490 signDown = (Char)m_sign[srcLine[x] - srcLineBelow[x+ 1]] ; 491 edgeType = signDown + signUpLine[x]; 492 resLine[x] = offsetClip[srcLine[x] + offset[edgeType]]; 493 494 signDownLine[x+1] = -signDown; 495 } 496 signDownLine[startX] = (Char)m_sign[srcLineBelow[startX] - srcLine[startX-1]]; 497 498 signTmpLine = signUpLine; 499 signUpLine = signDownLine; 500 signDownLine = signTmpLine; 501 502 srcLine += srcStride; 503 resLine += resStride; 504 } 505 506 //last line 507 srcLineBelow= srcLine+ srcStride; 508 lastLineStartX = isBelowAvail ? startX : (width -1); 509 lastLineEndX = isBelowRightAvail ? width : (width -1); 510 for(x= lastLineStartX; x< lastLineEndX; x++) 511 { 512 edgeType = m_sign[srcLine[x] - srcLineBelow[x+ 1]] + signUpLine[x]; 513 resLine[x] = offsetClip[srcLine[x] + offset[edgeType]]; 514 515 } 516 } 517 break; 518 case SAO_TYPE_EO_45: 519 { 520 offset += 2; 521 Char *signUpLine = m_signLineBuf1+1; 522 523 startX = isLeftAvail ? 0 : 1; 524 endX = isRightAvail ? width : (width -1); 525 526 //prepare 2nd line upper sign 527 Pel* srcLineBelow= srcLine+ srcStride; 528 for (x=startX-1; x< endX; x++) 529 { 530 signUpLine[x] = (Char)m_sign[srcLineBelow[x] - srcLine[x+1]]; 531 } 532 533 534 //first line 535 Pel* srcLineAbove= srcLine- srcStride; 536 firstLineStartX = isAboveAvail ? startX : (width -1 ); 537 firstLineEndX = isAboveRightAvail ? width : (width-1); 538 for(x= firstLineStartX; x< firstLineEndX; x++) 539 { 540 edgeType = m_sign[srcLine[x] - srcLineAbove[x+1]] -signUpLine[x-1]; 541 resLine[x] = offsetClip[srcLine[x] + offset[edgeType]]; 542 } 543 srcLine += srcStride; 544 resLine += resStride; 545 546 //middle lines 547 for (y= 1; y< height-1; y++) 548 { 549 srcLineBelow= srcLine+ srcStride; 550 551 for(x= startX; x< endX; x++) 552 { 553 signDown = (Char)m_sign[srcLine[x] - srcLineBelow[x-1]] ; 554 edgeType = signDown + signUpLine[x]; 555 resLine[x] = offsetClip[srcLine[x] + offset[edgeType]]; 556 signUpLine[x-1] = -signDown; 557 } 558 signUpLine[endX-1] = (Char)m_sign[srcLineBelow[endX-1] - srcLine[endX]]; 559 srcLine += srcStride; 560 resLine += resStride; 561 } 562 563 //last line 564 srcLineBelow= srcLine+ srcStride; 565 lastLineStartX = isBelowLeftAvail ? 0 : 1; 566 lastLineEndX = isBelowAvail ? endX : 1; 567 for(x= lastLineStartX; x< lastLineEndX; x++) 568 { 569 edgeType = m_sign[srcLine[x] - srcLineBelow[x-1]] + signUpLine[x]; 570 resLine[x] = offsetClip[srcLine[x] + offset[edgeType]]; 571 572 } 573 } 574 break; 575 case SAO_TYPE_BO: 576 { 577 Int shiftBits = ((compIdx == SAO_Y)?g_bitDepthY:g_bitDepthC)- NUM_SAO_BO_CLASSES_LOG2; 578 for (y=0; y< height; y++) 579 { 580 for (x=0; x< width; x++) 581 { 582 resLine[x] = offsetClip[ srcLine[x] + offset[srcLine[x] >> shiftBits] ]; 583 } 584 srcLine += srcStride; 585 resLine += resStride; 586 } 587 } 588 break; 589 default: 590 { 591 printf("Not a supported SAO types\n"); 592 assert(0); 593 exit(-1); 594 } 595 } 596 597 598 } 599 600 Void TComSampleAdaptiveOffset::offsetCTU(Int ctu, TComPicYuv* srcYuv, TComPicYuv* resYuv, SAOBlkParam& saoblkParam, TComPic* pPic) 601 { 602 Bool isLeftAvail,isRightAvail,isAboveAvail,isBelowAvail,isAboveLeftAvail,isAboveRightAvail,isBelowLeftAvail,isBelowRightAvail; 603 604 if( 605 (saoblkParam[SAO_Y ].modeIdc == SAO_MODE_OFF) && 606 (saoblkParam[SAO_Cb].modeIdc == SAO_MODE_OFF) && 607 (saoblkParam[SAO_Cr].modeIdc == SAO_MODE_OFF) 608 ) 609 { 610 return; 611 } 612 613 //block boundary availability 614 pPic->getPicSym()->deriveLoopFilterBoundaryAvailibility(ctu, isLeftAvail,isRightAvail,isAboveAvail,isBelowAvail,isAboveLeftAvail,isAboveRightAvail,isBelowLeftAvail,isBelowRightAvail); 615 616 Int yPos = (ctu / m_numCTUInWidth)*m_maxCUHeight; 617 Int xPos = (ctu % m_numCTUInWidth)*m_maxCUWidth; 618 Int height = (yPos + m_maxCUHeight > m_picHeight)?(m_picHeight- yPos):m_maxCUHeight; 619 Int width = (xPos + m_maxCUWidth > m_picWidth )?(m_picWidth - xPos):m_maxCUWidth; 620 621 for(Int compIdx= 0; compIdx < NUM_SAO_COMPONENTS; compIdx++) 622 { 623 SAOOffset& ctbOffset = saoblkParam[compIdx]; 624 625 if(ctbOffset.modeIdc != SAO_MODE_OFF) 626 { 627 Bool isLuma = (compIdx == SAO_Y); 628 Int formatShift= isLuma?0:1; 629 630 Int blkWidth = (width >> formatShift); 631 Int blkHeight = (height >> formatShift); 632 Int blkYPos = (yPos >> formatShift); 633 Int blkXPos = (xPos >> formatShift); 634 635 Int srcStride = isLuma?srcYuv->getStride():srcYuv->getCStride(); 636 Pel* srcBlk = getPicBuf(srcYuv, compIdx)+ (yPos >> formatShift)*srcStride+ (xPos >> formatShift); 637 638 Int resStride = isLuma?resYuv->getStride():resYuv->getCStride(); 639 Pel* resBlk = getPicBuf(resYuv, compIdx)+ blkYPos*resStride+ blkXPos; 640 641 offsetBlock( compIdx, ctbOffset.typeIdc, ctbOffset.offset 642 , srcBlk, resBlk, srcStride, resStride, blkWidth, blkHeight 643 , isLeftAvail, isRightAvail 644 , isAboveAvail, isBelowAvail 645 , isAboveLeftAvail, isAboveRightAvail 646 , isBelowLeftAvail, isBelowRightAvail 647 ); 648 } 649 } //compIdx 650 651 } 652 653 654 Void TComSampleAdaptiveOffset::SAOProcess(TComPic* pDecPic) 655 { 656 if(!m_picSAOEnabled[SAO_Y] && !m_picSAOEnabled[SAO_Cb] && !m_picSAOEnabled[SAO_Cr]) 657 { 658 return; 659 } 660 TComPicYuv* resYuv = pDecPic->getPicYuvRec(); 661 TComPicYuv* srcYuv = m_tempPicYuv; 662 resYuv->copyToPic(srcYuv); 663 for(Int ctu= 0; ctu < m_numCTUsPic; ctu++) 664 { 665 offsetCTU(ctu, srcYuv, resYuv, (pDecPic->getPicSym()->getSAOBlkParam())[ctu], pDecPic); 666 } //ctu 667 } 668 669 670 Pel* TComSampleAdaptiveOffset::getPicBuf(TComPicYuv* pPicYuv, Int compIdx) 671 { 672 Pel* pBuf = NULL; 673 switch(compIdx) 674 { 675 case SAO_Y: 676 { 677 pBuf = pPicYuv->getLumaAddr(); 678 } 679 break; 680 case SAO_Cb: 681 { 682 pBuf = pPicYuv->getCbAddr(); 683 } 684 break; 685 case SAO_Cr: 686 { 687 pBuf = pPicYuv->getCrAddr(); 688 } 689 break; 690 default: 691 { 692 printf("Not a legal component ID for SAO\n"); 693 assert(0); 694 exit(-1); 695 } 696 } 697 698 return pBuf; 699 } 700 #else 46 701 47 702 SAOParam::~SAOParam() … … 1364 2019 } 1365 2020 } 1366 2021 #endif 1367 2022 /** PCM LF disable process. 1368 2023 * \param pcPic picture (TComPic) pointer -
trunk/source/Lib/TLibCommon/TComSampleAdaptiveOffset.h
r313 r540 45 45 //! \{ 46 46 47 48 #if HM_CLEANUP_SAO 49 // ==================================================================================================================== 50 // Constants 51 // ==================================================================================================================== 52 53 #define MAX_SAO_TRUNCATED_BITDEPTH 10 54 // ==================================================================================================================== 55 // Class definition 56 // ==================================================================================================================== 57 extern UInt g_saoMaxOffsetQVal[NUM_SAO_COMPONENTS]; 58 59 class TComSampleAdaptiveOffset 60 { 61 public: 62 TComSampleAdaptiveOffset(); 63 virtual ~TComSampleAdaptiveOffset(); 64 Void SAOProcess(TComPic* pDecPic); 65 #if AUXILIARY_PICTURES 66 Void create( Int picWidth, Int picHeight, ChromaFormat chromaFormatIDC, UInt maxCUWidth, UInt maxCUHeight, UInt maxCUDepth ); 67 #else 68 Void create( Int picWidth, Int picHeight, UInt maxCUWidth, UInt maxCUHeight, UInt maxCUDepth ); 69 #endif 70 Void destroy(); 71 Void reconstructBlkSAOParams(TComPic* pic, SAOBlkParam* saoBlkParams); 72 Void PCMLFDisableProcess (TComPic* pcPic); 73 protected: 74 Void offsetBlock(Int compIdx, Int typeIdx, Int* offset, Pel* srcBlk, Pel* resBlk, Int srcStride, Int resStride, Int width, Int height 75 , Bool isLeftAvail, Bool isRightAvail, Bool isAboveAvail, Bool isBelowAvail, Bool isAboveLeftAvail, Bool isAboveRightAvail, Bool isBelowLeftAvail, Bool isBelowRightAvail); 76 Pel* getPicBuf(TComPicYuv* pPicYuv, Int compIdx); 77 Void invertQuantOffsets(Int compIdx, Int typeIdc, Int typeAuxInfo, Int* dstOffsets, Int* srcOffsets); 78 Void reconstructBlkSAOParam(SAOBlkParam& recParam, std::vector<SAOBlkParam*>& mergeList); 79 Int getMergeList(TComPic* pic, Int ctu, SAOBlkParam* blkParams, std::vector<SAOBlkParam*>& mergeList); 80 Void offsetCTU(Int ctu, TComPicYuv* srcYuv, TComPicYuv* resYuv, SAOBlkParam& saoblkParam, TComPic* pPic); 81 Void xPCMRestoration(TComPic* pcPic); 82 Void xPCMCURestoration ( TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth ); 83 Void xPCMSampleRestoration (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, TextType ttText); 84 protected: 85 UInt m_offsetStepLog2[NUM_SAO_COMPONENTS]; //offset step 86 Int* m_offsetClip[NUM_SAO_COMPONENTS]; //clip table for fast operation 87 Short* m_sign; //sign table for fast operation 88 TComPicYuv* m_tempPicYuv; //temporary buffer 89 Int m_picWidth; 90 Int m_picHeight; 91 Int m_maxCUWidth; 92 Int m_maxCUHeight; 93 Int m_numCTUInWidth; 94 Int m_numCTUInHeight; 95 Int m_numCTUsPic; 96 97 98 Int m_lineBufWidth; 99 Char* m_signLineBuf1; 100 Char* m_signLineBuf2; 101 private: 102 Bool m_picSAOEnabled[NUM_SAO_COMPONENTS]; 103 Int* m_offsetClipTable[NUM_SAO_COMPONENTS]; 104 Short* m_signTable; 105 106 }; 107 #else 108 47 109 // ==================================================================================================================== 48 110 // Constants … … 145 207 }; 146 208 209 #endif 210 147 211 //! \} 148 212 #endif -
trunk/source/Lib/TLibCommon/TComSlice.cpp
r494 r540 48 48 ParameterSetMap<TComVPS> ParameterSetManager::m_vpsMap(MAX_NUM_VPS); 49 49 Int ParameterSetManager::m_activeVPSId = -1; 50 #if IL_SL_SIGNALLING_N037151 TComSPS* TComSPS::m_pcSPS[MAX_LAYERS];52 TComPPS* TComPPS::m_pcPPS[MAX_LAYERS];53 #endif54 50 #endif 55 51 … … 80 76 , m_colFromL0Flag ( 1 ) 81 77 , m_colRefIdx ( 0 ) 82 #if SAO_CHROMA_LAMBDA83 , m_dLambdaLuma( 0.0 )84 , m_dLambdaChroma( 0.0 )85 #else86 , m_dLambda ( 0.0 )87 #endif88 78 , m_uiTLayer ( 0 ) 89 79 , m_bTLayerSwitchingFlag ( false ) … … 118 108 #endif 119 109 , m_bDiscardableFlag ( false ) 110 #if O0149_CROSS_LAYER_BLA_FLAG 111 , m_bCrossLayerBLAFlag ( false ) 112 #endif 120 113 #endif //SVC_EXTENSION 121 114 { … … 143 136 initEqualRef(); 144 137 138 for (Int component = 0; component < 3; component++) 139 { 140 m_lambdas[component] = 0.0; 141 } 142 145 143 for ( Int idx = 0; idx < MAX_NUM_REF; idx++ ) 146 144 { … … 157 155 initWpAcDcParam(); 158 156 m_saoEnabledFlag = false; 157 #if HM_CLEANUP_SAO 158 m_saoEnabledFlagChroma = false; 159 #endif 159 160 } 160 161 … … 276 277 } 277 278 iterPic++; 279 #if SVC_EXTENSION 280 // return NULL, if picture with requested POC is not in the list, otherwise iterator goes outside of the list 281 if( iterPic == rcListPic.end() ) 282 { 283 return NULL; 284 } 285 #endif 278 286 pcPic = *(iterPic); 279 287 } … … 308 316 } 309 317 318 #if POC_RESET_RPS 319 if( ((!pocHasMsb) && ((poc & (pocCycle-1)) == picPoc)) || ( pocHasMsb && (poc == picPoc)) ) 320 #else 310 321 if (poc == picPoc) 322 #endif 311 323 { 312 324 if (pcPic->getIsLongTerm()) … … 357 369 } 358 370 359 #if FIX1071360 371 #if SVC_EXTENSION 361 372 Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr, TComPic** ilpPic) … … 363 374 Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr ) 364 375 #endif 365 #else 366 Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic ) 367 #endif 368 { 369 #if FIX1071 376 { 370 377 if (!checkNumPocTotalCurr) 371 #endif372 378 { 373 379 if (m_eSliceType == I_SLICE) … … 522 528 memset( refResamplingLayer, 0, sizeof( refResamplingLayer ) ); 523 529 #endif 530 #if !RESAMPLING_CONSTRAINT_BUG_FIX 524 531 const Window &scalEL = getSPS()->getScaledRefLayerWindow(m_interLayerPredLayerIdc[i]); 525 532 Int scalingOffset = ((scalEL.getWindowLeftOffset() == 0 ) && … … 528 535 (scalEL.getWindowBottomOffset() == 0 ) 529 536 ); 537 #endif 530 538 531 539 for( i=0; i < m_activeNumILRRefIdx; i++ ) 532 540 { 533 541 UInt refLayerIdc = m_interLayerPredLayerIdc[i]; 542 #if RESAMPLING_CONSTRAINT_BUG_FIX 543 #if O0098_SCALED_REF_LAYER_ID 544 const Window &scalEL = getSPS()->getScaledRefLayerWindowForLayer(m_pcVPS->getRefLayerId( m_layerId, m_interLayerPredLayerIdc[i] )); 545 #else 546 const Window &scalEL = getSPS()->getScaledRefLayerWindow(m_interLayerPredLayerIdc[i]); 547 #endif 548 Int scalingOffset = ((scalEL.getWindowLeftOffset() == 0 ) && 549 (scalEL.getWindowRightOffset() == 0 ) && 550 (scalEL.getWindowTopOffset() == 0 ) && 551 (scalEL.getWindowBottomOffset() == 0 ) 552 ); 553 #endif 534 554 if(!( g_posScalingFactor[refLayerIdc][0] == 65536 && g_posScalingFactor[refLayerIdc][1] == 65536 ) || (!scalingOffset)) // ratio 1x 535 555 { … … 585 605 Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr; 586 606 #endif //SVC_EXTENSION 587 #if FIX1071 607 588 608 if (checkNumPocTotalCurr) 589 609 { … … 615 635 m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); 616 636 } 617 #endif618 637 619 638 #if M0457_IL_SAMPLE_PRED_ONLY_FLAG … … 932 951 numRpsCurrTempList += getNumILRRefIdx(); 933 952 #endif 934 953 } 935 954 #endif 936 955 … … 1038 1057 * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". 1039 1058 */ 1059 #if NO_CLRAS_OUTPUT_FLAG 1060 Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag) 1061 #else 1040 1062 Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic) 1063 #endif 1041 1064 { 1042 1065 TComPic* rpcPic; … … 1056 1079 rpcPic = *(iterPic); 1057 1080 rpcPic->setCurrSliceIdx(0); 1081 #if NO_CLRAS_OUTPUT_FLAG 1082 if (noClrasOutputFlag) 1083 { 1084 if (rpcPic->getPOC() != pocCurr) rpcPic->getSlice(0)->setReferenced(false); // all layers 1085 } 1086 else 1087 { 1088 if (rpcPic->getPOC() != pocCurr && rpcPic->getLayerId() == m_layerId) rpcPic->getSlice(0)->setReferenced(false); // only current layer 1089 } 1090 #else 1058 1091 if (rpcPic->getPOC() != pocCurr) rpcPic->getSlice(0)->setReferenced(false); 1092 #endif 1059 1093 iterPic++; 1060 1094 } … … 1160 1194 m_colFromL0Flag = pSrc->m_colFromL0Flag; 1161 1195 m_colRefIdx = pSrc->m_colRefIdx; 1162 #if SAO_CHROMA_LAMBDA 1163 m_dLambdaLuma = pSrc->m_dLambdaLuma; 1164 m_dLambdaChroma = pSrc->m_dLambdaChroma; 1165 #else 1166 m_dLambda = pSrc->m_dLambda; 1167 #endif 1196 setLambdas(pSrc->getLambdas()); 1168 1197 for (i = 0; i < 2; i++) 1169 1198 { … … 1490 1519 assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); 1491 1520 //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture 1492 if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_T LA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N)1521 if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) 1493 1522 { 1494 1523 assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); … … 1649 1678 /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set 1650 1679 */ 1651 #if FIX10711652 1680 Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP) 1653 #else1654 Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet)1655 #endif1656 1681 { 1657 1682 TComPic* rpcPic; … … 1678 1703 // and should be added to the explicit Reference Picture Set 1679 1704 pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); 1680 #if FIX10711681 1705 pcRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP)); 1682 #else1683 pcRPS->setUsed(k, pReferencePictureSet->getUsed(i));1684 #endif1685 1706 if(pcRPS->getDeltaPOC(k) < 0) 1686 1707 { … … 1834 1855 TComVPS *vps = getVPS(); 1835 1856 UInt retVal, layerId = getLayerId(); 1857 #if O0096_REP_FORMAT_INDEX 1858 if ( layerId == 0 ) 1859 { 1860 retVal = sps->getPicWidthInLumaSamples(); 1861 } 1862 else 1863 { 1864 retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getPicWidthVpsInLumaSamples(); 1865 } 1866 #else 1836 1867 if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) 1837 1868 { … … 1842 1873 retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getPicWidthVpsInLumaSamples(); 1843 1874 } 1875 #endif 1844 1876 return retVal; 1845 1877 } … … 1849 1881 TComVPS *vps = getVPS(); 1850 1882 UInt retVal, layerId = getLayerId(); 1883 #if O0096_REP_FORMAT_INDEX 1884 if( layerId == 0 ) 1885 { 1886 retVal = sps->getPicHeightInLumaSamples(); 1887 } 1888 else 1889 { 1890 retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getPicHeightVpsInLumaSamples(); 1891 } 1892 #else 1851 1893 if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) 1852 1894 { … … 1857 1899 retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getPicHeightVpsInLumaSamples(); 1858 1900 } 1901 #endif 1859 1902 return retVal; 1860 1903 } … … 1873 1916 UInt retVal, layerId = getLayerId(); 1874 1917 #endif 1918 #if O0096_REP_FORMAT_INDEX 1919 if( layerId == 0 ) 1920 { 1921 retVal = sps->getChromaFormatIdc(); 1922 } 1923 else 1924 { 1925 retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getChromaFormatVpsIdc(); 1926 } 1927 #else 1875 1928 if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) 1876 1929 { … … 1881 1934 retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getChromaFormatVpsIdc(); 1882 1935 } 1936 #endif 1883 1937 return retVal; 1884 1938 } … … 1888 1942 TComVPS *vps = getVPS(); 1889 1943 UInt retVal, layerId = getLayerId(); 1944 #if O0096_REP_FORMAT_INDEX 1945 if( layerId == 0 ) 1946 { 1947 retVal = sps->getBitDepthY(); 1948 } 1949 else 1950 { 1951 retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getBitDepthVpsLuma(); 1952 } 1953 #else 1890 1954 if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) 1891 1955 { … … 1896 1960 retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getBitDepthVpsLuma(); 1897 1961 } 1962 #endif 1898 1963 return retVal; 1899 1964 } … … 1903 1968 TComVPS *vps = getVPS(); 1904 1969 UInt retVal, layerId = getLayerId(); 1970 #if O0096_REP_FORMAT_INDEX 1971 if( layerId == 0 ) 1972 { 1973 retVal = sps->getBitDepthC(); 1974 } 1975 else 1976 { 1977 retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getBitDepthVpsChroma(); 1978 } 1979 #else 1905 1980 if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) 1906 1981 { … … 1911 1986 retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getBitDepthVpsChroma(); 1912 1987 } 1988 #endif 1913 1989 return retVal; 1914 1990 } … … 2023 2099 ::memset(m_pocLsbNotPresentFlag, 0, sizeof(m_pocLsbNotPresentFlag)); 2024 2100 #endif 2101 #if O0223_PICTURE_TYPES_ALIGN_FLAG 2102 m_crossLayerPictureTypeAlignFlag = true; 2103 #endif 2025 2104 #if N0147_IRAP_ALIGN_FLAG 2026 2105 m_crossLayerIrapAlignFlag = true; … … 2042 2121 } 2043 2122 #endif 2123 #if VPS_VUI_TILES_NOT_IN_USE__FLAG 2124 m_tilesNotInUseFlag = true; 2125 ::memset(m_tilesInUseFlag, 0, sizeof(m_tilesInUseFlag)); 2126 ::memset(m_loopFilterNotAcrossTilesFlag, 0, sizeof(m_loopFilterNotAcrossTilesFlag)); 2127 #endif 2044 2128 #if TILE_BOUNDARY_ALIGNED_FLAG 2045 2129 ::memset(m_tileBoundariesAlignedFlag, 0, sizeof(m_tileBoundariesAlignedFlag)); 2046 2130 #endif 2131 #if VPS_VUI_WPP_NOT_IN_USE__FLAG 2132 m_wppNotInUseFlag = true; 2133 ::memset(m_wppInUseFlag, 0, sizeof(m_wppInUseFlag)); 2134 #endif 2047 2135 #if N0160_VUI_EXT_ILP_REF 2048 2136 m_numIlpRestrictedRefLayers = false; … … 2050 2138 ::memset(m_ctuBasedOffsetEnabledFlag, 0, sizeof(m_ctuBasedOffsetEnabledFlag)); 2051 2139 ::memset(m_minHorizontalCtuOffsetPlus1, 0, sizeof(m_minHorizontalCtuOffsetPlus1)); 2140 #endif 2141 #if VPS_VUI_VIDEO_SIGNAL 2142 m_vidSigPresentVpsFlag=true; 2143 m_vpsVidSigInfo=1; 2144 ::memset( m_vpsVidSigIdx, 0, sizeof(m_vpsVidSigIdx) ); 2145 m_vpsVidSigIdx[0]=0; 2146 for (Int i=0; i < 16; i++) 2147 { 2148 m_vpsVidFormat[i] = 5; 2149 m_vpsFullRangeFlag[i] = false; 2150 m_vpsColorPrimaries[i] = 2; 2151 m_vpsTransChar[i] = 2; 2152 m_vpsMatCoeff[i] = 2; 2153 } 2052 2154 #endif 2053 2155 #if VPS_VUI_BITRATE_PICRATE … … 2064 2166 #if VIEW_ID_RELATED_SIGNALING 2065 2167 ::memset(m_viewIdVal, 0, sizeof(m_viewIdVal)); 2168 #endif 2169 #if O0092_0094_DEPENDENCY_CONSTRAINT 2170 for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++) 2171 { 2172 m_numberRefLayers[i] = 0; 2173 for (Int j = 0; j < MAX_NUM_LAYER_IDS; j++) 2174 { 2175 m_recursiveRefLayerFlag[i][j] = 0; 2176 } 2177 } 2178 #endif 2179 #if VPS_DPB_SIZE_TABLE 2180 ::memset( m_subLayerFlagInfoPresentFlag, 0, sizeof(m_subLayerFlagInfoPresentFlag ) ); 2181 ::memset( m_subLayerDpbInfoPresentFlag, 0, sizeof(m_subLayerDpbInfoPresentFlag ) ); 2182 ::memset( m_maxVpsDecPicBufferingMinus1, 0, sizeof(m_maxVpsDecPicBufferingMinus1 ) ); 2183 ::memset( m_maxVpsNumReorderPics, 0, sizeof(m_maxVpsNumReorderPics ) ); 2184 ::memset( m_maxVpsLatencyIncreasePlus1, 0, sizeof(m_maxVpsLatencyIncreasePlus1 ) ); 2185 ::memset( m_numSubDpbs , 0, sizeof(m_numSubDpbs) ); 2066 2186 #endif 2067 2187 } … … 2117 2237 } 2118 2238 #endif 2119 2120 #if IL_SL_SIGNALLING_N0371 2121 Bool TComVPS::checkLayerDependency(UInt i, UInt j) 2122 { 2123 if( this->getDirectDependencyFlag(i, j) == true ) 2124 { 2125 return true; 2126 } 2127 else 2128 { 2129 for(UInt k=i-1; k>j; k--) 2130 { 2131 if( this->getDirectDependencyFlag(i, k) == true ) 2132 { 2133 checkLayerDependency( k,j ); 2134 } 2135 } 2136 } 2137 return false; 2239 #if VPS_DPB_SIZE_TABLE 2240 Void TComVPS::deriveNumberOfSubDpbs() 2241 { 2242 // Derive number of sub-DPBs 2243 // For output layer set 0 2244 setNumSubDpbs(0, 1); 2245 // For other output layer sets 2246 for( Int i = 1; i < getNumOutputLayerSets(); i++) 2247 { 2248 setNumSubDpbs( i, getNumLayersInIdList( getOutputLayerSetIdx(i)) ); 2249 } 2250 } 2251 #endif 2252 #if VPS_VUI_TILES_NOT_IN_USE__FLAG 2253 Void TComVPS::setTilesNotInUseFlag(Bool x) 2254 { 2255 m_tilesNotInUseFlag = x; 2256 if (m_tilesNotInUseFlag) 2257 { 2258 for (int i = 0; i < getMaxLayers(); i++) 2259 { 2260 m_tilesInUseFlag[i] = m_loopFilterNotAcrossTilesFlag[i] = m_tilesNotInUseFlag; 2261 } 2262 } 2263 #if TILE_BOUNDARY_ALIGNED_FLAG 2264 if (m_tilesNotInUseFlag) 2265 { 2266 for (int i = 1; i < getMaxLayers(); i++) 2267 { 2268 for(int j = 0; j < getNumDirectRefLayers(getLayerIdInNuh(i)); j++) 2269 { 2270 setTileBoundariesAlignedFlag(i, j, m_tilesNotInUseFlag); 2271 } 2272 } 2273 } 2274 #endif 2275 } 2276 #endif 2277 #if VPS_VUI_WPP_NOT_IN_USE__FLAG 2278 Void TComVPS::setWppNotInUseFlag(Bool x) 2279 { 2280 m_wppNotInUseFlag = x; 2281 if (m_wppNotInUseFlag) 2282 { 2283 for (int i = 0; i < getMaxLayers(); i++) 2284 { 2285 m_wppInUseFlag[i] = m_wppNotInUseFlag; 2286 } 2287 } 2288 } 2289 #endif 2290 #if O0092_0094_DEPENDENCY_CONSTRAINT 2291 Void TComVPS::setRefLayersFlags(Int currLayerId) 2292 { 2293 for (Int i = 0; i < getNumDirectRefLayers(currLayerId); i++) 2294 { 2295 UInt refLayerId = getRefLayerId(currLayerId, i); 2296 setRecursiveRefLayerFlag(currLayerId, refLayerId, true); 2297 for (Int k = 0; k < MAX_NUM_LAYER_IDS; k++) 2298 { 2299 setRecursiveRefLayerFlag(currLayerId, k, (getRecursiveRefLayerFlag(currLayerId, k) | getRecursiveRefLayerFlag(refLayerId, k))); 2300 } 2301 } 2302 } 2303 2304 Void TComVPS::setNumRefLayers(Int currLayerId) 2305 { 2306 for (Int i = 0; i <= getMaxLayers(); i++) 2307 { 2308 UInt iNuhLId = getLayerIdInNuh(i); 2309 setRefLayersFlags(iNuhLId); 2310 for (UInt j = 0; j < MAX_NUM_LAYER_IDS; j++) 2311 { 2312 m_numberRefLayers[iNuhLId] += (getRecursiveRefLayerFlag(iNuhLId, j) == true ? 1 : 0); 2313 } 2314 } 2138 2315 } 2139 2316 #endif … … 2224 2401 #if REPN_FORMAT_IN_VPS 2225 2402 , m_updateRepFormatFlag (false) 2403 #if O0096_REP_FORMAT_INDEX 2404 , m_updateRepFormatIndex (0) 2405 #endif 2406 #endif 2407 #if SCALINGLIST_INFERRING 2408 , m_inferScalingListFlag ( false ) 2409 , m_scalingListRefLayerId ( 0 ) 2226 2410 #endif 2227 2411 #endif //SVC_EXTENSION … … 2248 2432 TComSPS::~TComSPS() 2249 2433 { 2434 #if SCALINGLIST_INFERRING 2435 if( !m_inferScalingListFlag ) 2436 #endif 2250 2437 delete m_scalingList; 2251 2438 m_RPSList.destroy(); … … 2373 2560 const Int TComSPS::m_winUnitX[]={1,2,2,1}; 2374 2561 const Int TComSPS::m_winUnitY[]={1,2,1,1}; 2562 2563 #if O0098_SCALED_REF_LAYER_ID 2564 Window& TComSPS::getScaledRefLayerWindowForLayer(Int layerId) 2565 { 2566 static Window win; 2567 2568 for (Int i = 0; i < m_numScaledRefLayerOffsets; i++) 2569 { 2570 if (layerId == m_scaledRefLayerId[i]) 2571 { 2572 return m_scaledRefLayerWindow[i]; 2573 } 2574 } 2575 2576 win.resetWindow(); // scaled reference layer offsets are inferred to be zero when not present 2577 return win; 2578 } 2579 #endif 2375 2580 2376 2581 TComPPS::TComPPS() … … 2407 2612 , m_listsModificationPresentFlag( 0) 2408 2613 , m_numExtraSliceHeaderBits(0) 2614 #if SCALINGLIST_INFERRING 2615 , m_inferScalingListFlag ( false ) 2616 , m_scalingListRefLayerId ( 0 ) 2617 #endif 2409 2618 { 2410 2619 m_scalingList = new TComScalingList; … … 2423 2632 m_puiRowHeight = NULL; 2424 2633 } 2634 2635 #if SCALINGLIST_INFERRING 2636 if( !m_inferScalingListFlag ) 2637 #endif 2425 2638 delete m_scalingList; 2426 2639 } … … 2640 2853 /** set default quantization matrix to array 2641 2854 */ 2642 #if IL_SL_SIGNALLING_N03712643 Void TComSlice::setDefaultScalingList( UInt layerId )2644 #else2645 2855 Void TComSlice::setDefaultScalingList() 2646 #endif2647 2856 { 2648 2857 for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) … … 2650 2859 for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) 2651 2860 { 2652 #if IL_SL_SIGNALLING_N0371 2653 getScalingList()->processDefaultMarix(sizeId, listId, layerId); 2654 #else 2655 getScalingList()->processDefaultMarix(sizeId, listId); 2656 #endif 2861 getScalingList()->processDefaultMatrix(sizeId, listId); 2657 2862 } 2658 2863 } … … 2829 3034 * \param Index of input matrix 2830 3035 */ 2831 #if IL_SL_SIGNALLING_N0371 2832 Void TComScalingList::processDefaultMarix(UInt sizeId, UInt listId, UInt layerId) 2833 #else 2834 Void TComScalingList::processDefaultMarix(UInt sizeId, UInt listId) 2835 #endif 2836 { 2837 #if IL_SL_SIGNALLING_N0371 2838 Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); 2839 UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; 2840 Int *src = getScalingListDefaultAddress(sizeId, listId); 2841 #endif 2842 3036 Void TComScalingList::processDefaultMatrix(UInt sizeId, UInt listId) 3037 { 2843 3038 ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); 2844 2845 #if IL_SL_SIGNALLING_N03712846 for(i = 0; i < coefNum; i++)2847 {2848 ref_scalingListCoef[layerId][sizeId][listId][i] = src[scan[i]];2849 }2850 #endif2851 2852 3039 setScalingListDC(sizeId,listId,SCALING_LIST_DC); 2853 #if IL_SL_SIGNALLING_N03712854 ref_scalingListDC[layerId][sizeId][listId] = SCALING_LIST_DC;2855 #endif2856 3040 } 2857 3041 2858 3042 /** check DC value of matrix for default matrix signaling 2859 3043 */ 2860 #if IL_SL_SIGNALLING_N03712861 Void TComScalingList::checkDcOfMatrix( UInt layerId )2862 #else2863 3044 Void TComScalingList::checkDcOfMatrix() 2864 #endif2865 3045 { 2866 3046 for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) … … 2871 3051 if(getScalingListDC(sizeId,listId) == 0) 2872 3052 { 2873 #if IL_SL_SIGNALLING_N0371 2874 processDefaultMarix(sizeId, listId, layerId); 2875 #else 2876 processDefaultMarix(sizeId, listId); 2877 #endif 3053 processDefaultMatrix(sizeId, listId); 2878 3054 } 2879 3055 } … … 2956 3132 m_activeVPSId = vpsId; 2957 3133 m_activeSPSId = spsId; 2958 2959 #if IL_SL_SIGNALLING_N03712960 activeRefPPSId[ sps->getLayerId() ] = ppsId;2961 activeRefSPSId[ sps->getLayerId() ] = spsId;2962 #endif2963 3134 2964 3135 return true; … … 3068 3239 #endif 3069 3240 3070 VoidTComSlice::setBaseColPic( TComList<TComPic*>& rcListPic, UInt refLayerIdc )3241 Bool TComSlice::setBaseColPic( TComList<TComPic*>& rcListPic, UInt refLayerIdc ) 3071 3242 { 3072 3243 if(m_layerId == 0) 3073 3244 { 3074 3245 memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) ); 3075 return ;3246 return false; 3076 3247 } 3077 3248 #if POC_RESET_FLAG 3078 if( this->getPocResetFlag() ) 3079 { 3080 setBaseColPic(refLayerIdc, xGetRefPic(rcListPic, 0)); 3249 TComPic* pic = xGetRefPic( rcListPic, m_bPocResetFlag ? 0 : m_iPOC ); 3250 3251 if( pic ) 3252 { 3253 setBaseColPic(refLayerIdc, pic ); 3081 3254 } 3082 3255 else 3083 3256 { 3084 setBaseColPic(refLayerIdc, xGetRefPic(rcListPic, getPOC())); 3085 } 3257 return false; 3258 } 3259 3260 return true; 3086 3261 #else 3087 3262 setBaseColPic(refLayerIdc, xGetRefPic(rcListPic, getPOC())); -
trunk/source/Lib/TLibCommon/TComSlice.h
r494 r540 156 156 Void setScalingListPresentFlag (Bool b) { m_scalingListPresentFlag = b; } 157 157 Bool getScalingListPresentFlag () { return m_scalingListPresentFlag; } 158 159 #if IL_SL_SIGNALLING_N0371160 UInt m_layerId;161 162 Void setPredScalingListFlag (Bool b) { m_predScalingListFlag = b; }163 Bool getPredScalingListFlag () { return m_predScalingListFlag; }164 Void setScalingListRefLayerId (UInt b) { m_scalingListRefLayerId = b; }165 UInt getScalingListRefLayerId () { return m_scalingListRefLayerId; }166 #endif167 168 158 Int* getScalingListAddress (UInt sizeId, UInt listId) { return m_scalingListCoef[sizeId][listId]; } //!< get matrix coefficient 169 159 Bool checkPredMode (UInt sizeId, UInt listId); … … 171 161 UInt getRefMatrixId (UInt sizeId, UInt listId) { return m_refMatrixId[sizeId][listId]; } //!< get reference matrix ID 172 162 Int* getScalingListDefaultAddress (UInt sizeId, UInt listId); //!< get default matrix coefficient 173 174 #if IL_SL_SIGNALLING_N0371 175 Void processDefaultMarix (UInt sizeId, UInt listId, UInt layerId ); 176 #else 177 Void processDefaultMarix (UInt sizeId, UInt listId); 178 #endif 179 163 Void processDefaultMatrix (UInt sizeId, UInt listId); 180 164 Void setScalingListDC (UInt sizeId, UInt listId, UInt u) { m_scalingListDC[sizeId][listId] = u; } //!< set DC value 181 165 182 166 Int getScalingListDC (UInt sizeId, UInt listId) { return m_scalingListDC[sizeId][listId]; } //!< get DC value 183 184 #if IL_SL_SIGNALLING_N0371185 Void setLayerId(UInt layerId) { m_layerId = layerId; }186 UInt getLayerId() { return m_layerId; }187 Void checkDcOfMatrix ( UInt m_layerId );188 #else189 167 Void checkDcOfMatrix (); 190 #endif191 192 168 Void processRefMatrix (UInt sizeId, UInt listId , UInt refListId ); 193 169 Bool xParseScalingList (Char* pchFile); … … 200 176 UInt m_refMatrixId [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< RefMatrixID 201 177 Bool m_scalingListPresentFlag; //!< flag for using default matrix 202 203 #if IL_SL_SIGNALLING_N0371204 Bool m_predScalingListFlag; //!< flag for inter-layer scaling-list prediction205 UInt m_scalingListRefLayerId; //!< scaling_list_ref_layer_id206 #endif207 208 178 UInt m_predMatrixId [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< reference list index 209 179 Int *m_scalingListCoef [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< quantization matrix … … 436 406 class RepFormat 437 407 { 408 #if REPN_FORMAT_CONTROL_FLAG 409 Bool m_chromaAndBitDepthVpsPresentFlag; 410 #endif 438 411 #if AUXILIARY_PICTURES 439 412 ChromaFormat m_chromaFormatVpsIdc; … … 449 422 public: 450 423 RepFormat(); 424 425 #if REPN_FORMAT_CONTROL_FLAG 426 Bool getChromaAndBitDepthVpsPresentFlag() { return m_chromaAndBitDepthVpsPresentFlag; } 427 void setChromaAndBitDepthVpsPresentFlag(Bool x) { m_chromaAndBitDepthVpsPresentFlag = x; } 428 #endif 451 429 452 430 #if AUXILIARY_PICTURES … … 504 482 Int m_layerSetLayerIdList[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_ID_PLUS1]; 505 483 Int m_numLayerInIdList[MAX_VPS_LAYER_SETS_PLUS1]; 506 #endif507 #if IL_SL_SIGNALLING_N0371508 Bool m_scalingListLayerDependency[MAX_LAYERS][MAX_LAYERS]; // layer dependency for scaling list509 484 #endif 510 485 #if VPS_EXTN_OFFSET … … 555 530 #if M0457_PREDICTION_INDICATIONS 556 531 UInt m_directDepTypeLen; 532 #if O0096_DEFAULT_DEPENDENCY_TYPE 533 Bool m_defaultDirectDependencyTypeFlag; 534 UInt m_defaultDirectDependencyType; 535 #endif 557 536 UInt m_directDependencyType[MAX_VPS_LAYER_ID_PLUS1][MAX_VPS_LAYER_ID_PLUS1]; 558 537 #endif … … 569 548 Bool m_pocLsbNotPresentFlag[MAX_VPS_LAYER_ID_PLUS1]; 570 549 #endif 550 #if O0223_PICTURE_TYPES_ALIGN_FLAG 551 Bool m_crossLayerPictureTypeAlignFlag; 552 #endif 571 553 #if N0147_IRAP_ALIGN_FLAG 572 554 Bool m_crossLayerIrapAlignFlag; … … 582 564 Bool m_maxTidRefPresentFlag; 583 565 #endif 566 #if VPS_TSLAYERS 567 Bool m_maxTSLayersPresentFlag; 568 UInt m_maxTSLayerMinus1[MAX_VPS_LAYER_ID_PLUS1 - 1]; 569 #endif 584 570 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 585 571 Bool m_singleLayerForNonIrapFlag; 586 572 #endif 573 #if HIGHER_LAYER_IRAP_SKIP_FLAG 574 Bool m_higherLayerIrapSkipFlag; 575 #endif 576 #if VPS_VUI_TILES_NOT_IN_USE__FLAG 577 Bool m_tilesNotInUseFlag; 578 Bool m_tilesInUseFlag[MAX_VPS_LAYER_ID_PLUS1]; 579 Bool m_loopFilterNotAcrossTilesFlag[MAX_VPS_LAYER_ID_PLUS1]; 580 #endif 587 581 #if TILE_BOUNDARY_ALIGNED_FLAG 588 582 Bool m_tileBoundariesAlignedFlag[MAX_VPS_LAYER_ID_PLUS1][MAX_VPS_LAYER_ID_PLUS1]; 583 #endif 584 #if VPS_VUI_WPP_NOT_IN_USE__FLAG 585 Bool m_wppNotInUseFlag; 586 Bool m_wppInUseFlag[MAX_VPS_LAYER_ID_PLUS1]; 589 587 #endif 590 588 #if N0160_VUI_EXT_ILP_REF … … 593 591 Bool m_ctuBasedOffsetEnabledFlag [MAX_VPS_LAYER_ID_PLUS1][MAX_VPS_LAYER_ID_PLUS1]; 594 592 Int m_minHorizontalCtuOffsetPlus1 [MAX_VPS_LAYER_ID_PLUS1][MAX_VPS_LAYER_ID_PLUS1]; 593 #endif 594 #if VPS_VUI_VIDEO_SIGNAL 595 Bool m_vidSigPresentVpsFlag; 596 Int m_vpsVidSigInfo; 597 Int m_vpsVidSigIdx[MAX_VPS_LAYER_ID_PLUS1]; 598 Int m_vpsVidFormat[16]; 599 Bool m_vpsFullRangeFlag[16]; 600 Int m_vpsColorPrimaries[16]; 601 Int m_vpsTransChar[16]; 602 Int m_vpsMatCoeff[16]; 595 603 #endif 596 604 #if VPS_VUI_BITRATE_PICRATE … … 604 612 Int m_avgPicRate [MAX_VPS_LAYER_SETS_PLUS1][MAX_TLAYER]; 605 613 #endif 614 #if O0153_ALT_OUTPUT_LAYER_FLAG 615 Bool m_altOutputLayerFlag; 616 #endif 606 617 #if REPN_FORMAT_IN_VPS 607 618 Bool m_repFormatIdxPresentFlag; … … 617 628 #if O0215_PHASE_ALIGNMENT 618 629 Bool m_phaseAlignFlag; 630 #endif 631 632 #if O0092_0094_DEPENDENCY_CONSTRAINT 633 Int m_numberRefLayers[MAX_NUM_LAYER_IDS]; // number of direct and indirect reference layers of a coding layer 634 Bool m_recursiveRefLayerFlag[MAX_NUM_LAYER_IDS][MAX_NUM_LAYER_IDS]; // flag to indicate if j-th layer is a direct or indirect reference layer of i-th layer 635 #endif 636 #if VPS_DPB_SIZE_TABLE 637 Bool m_subLayerFlagInfoPresentFlag [MAX_VPS_OP_LAYER_SETS_PLUS1]; 638 Bool m_subLayerDpbInfoPresentFlag [MAX_VPS_OP_LAYER_SETS_PLUS1][MAX_LAYERS]; 639 Int m_maxVpsDecPicBufferingMinus1 [MAX_VPS_OP_LAYER_SETS_PLUS1][MAX_LAYERS][MAX_TLAYER]; 640 Int m_maxVpsNumReorderPics [MAX_VPS_OP_LAYER_SETS_PLUS1][MAX_LAYERS]; 641 Int m_maxVpsLatencyIncreasePlus1 [MAX_VPS_OP_LAYER_SETS_PLUS1][MAX_LAYERS]; 642 Int m_numSubDpbs [MAX_VPS_OP_LAYER_SETS_PLUS1]; 619 643 #endif 620 644 #endif //SVC_EXTENSION … … 683 707 Void deriveLayerIdListVariables(); 684 708 #endif 685 686 #if IL_SL_SIGNALLING_N0371 687 Bool checkLayerDependency(UInt i, UInt j); 688 Bool getScalingListLayerDependency ( UInt layerId, UInt refLayerId ) { return m_scalingListLayerDependency[layerId][refLayerId]; } 689 Void setScalingListLayerDependency ( UInt layerId, UInt refLayerId, Bool val ) { m_scalingListLayerDependency[layerId][refLayerId] = val; } 690 #endif 691 709 #if VPS_DPB_SIZE_TABLE 710 Void deriveNumberOfSubDpbs(); 711 #endif 712 713 #if O0092_0094_DEPENDENCY_CONSTRAINT 714 Void setRefLayersFlags(Int currLayerId); 715 Bool getRecursiveRefLayerFlag(Int currLayerId, Int refLayerId) { return m_recursiveRefLayerFlag[currLayerId][refLayerId];} 716 Void setRecursiveRefLayerFlag(Int currLayerId, Int refLayerId, Bool x) { m_recursiveRefLayerFlag[currLayerId][refLayerId] = x; } 717 Int getNumRefLayers(Int currLayerId) { return m_numberRefLayers[currLayerId]; } 718 Void setNumRefLayers(Int currLayerId); 719 #endif 692 720 #if VPS_RENAME 693 721 UInt getMaxLayerId() { return m_maxLayerId; } … … 764 792 UInt getDirectDepTypeLen() { return m_directDepTypeLen; } 765 793 Void setDirectDepTypeLen(UInt x) { m_directDepTypeLen = x; } 766 794 #if O0096_DEFAULT_DEPENDENCY_TYPE 795 Bool getDefaultDirectDependencyTypeFlag() { return m_defaultDirectDependencyTypeFlag; } 796 Void setDefaultDirectDependecyTypeFlag(Bool x) { m_defaultDirectDependencyTypeFlag = x; } 797 UInt getDefaultDirectDependencyType() { return m_defaultDirectDependencyType; } 798 Void setDefaultDirectDependecyType(UInt x) { m_defaultDirectDependencyType = x; } 799 #endif 767 800 UInt getDirectDependencyType(Int currLayerId, Int refLayerId) { return m_directDependencyType[currLayerId][refLayerId]; } 768 801 Void setDirectDependencyType(Int currLayerId, Int refLayerId, UInt x) { m_directDependencyType[currLayerId][refLayerId] = x; } … … 791 824 Void setPocLsbNotPresentFlag(Int i, Bool x) { m_pocLsbNotPresentFlag[i] = x; } 792 825 #endif 826 #if O0223_PICTURE_TYPES_ALIGN_FLAG 827 Bool getCrossLayerPictureTypeAlignFlag() { return m_crossLayerPictureTypeAlignFlag; } 828 Void setCrossLayerPictureTypeAlignFlag(Bool x) { m_crossLayerPictureTypeAlignFlag = x; } 829 #endif 793 830 #if N0147_IRAP_ALIGN_FLAG 794 831 Bool getCrossLayerIrapAlignFlag() { return m_crossLayerIrapAlignFlag; } … … 808 845 Void setMaxTidRefPresentFlag(Bool x) { m_maxTidRefPresentFlag = x;} 809 846 #endif 847 #if VPS_TSLAYERS 848 Bool getMaxTSLayersPresentFlag() { return m_maxTSLayersPresentFlag ;} 849 Void setMaxTSLayersPresentFlag(Bool x) { m_maxTSLayersPresentFlag = x;} 850 UInt getMaxTSLayersMinus1(Int layerId) { return m_maxTSLayerMinus1[layerId];} 851 Void setMaxTSLayersMinus1(Int layerId, UInt maxTSublayer) { m_maxTSLayerMinus1[layerId] = maxTSublayer;} 852 #endif 810 853 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 811 854 Bool getSingleLayerForNonIrapFlag() { return m_singleLayerForNonIrapFlag; } 812 855 Void setSingleLayerForNonIrapFlag(Bool x) { m_singleLayerForNonIrapFlag = x; } 813 856 #endif 857 #if HIGHER_LAYER_IRAP_SKIP_FLAG 858 Bool getHigherLayerIrapSkipFlag() { return m_higherLayerIrapSkipFlag; } 859 Void setHigherLayerIrapSkipFlag(Bool x) { m_higherLayerIrapSkipFlag = x; } 860 #endif 861 #if VPS_VUI_TILES_NOT_IN_USE__FLAG 862 Bool getTilesNotInUseFlag() { return m_tilesNotInUseFlag; } 863 Void setTilesNotInUseFlag(Bool x); 864 Bool getTilesInUseFlag(Int currLayerId) { return m_tilesInUseFlag[currLayerId]; } 865 Void setTilesInUseFlag(Int currLayerId, Bool x) { m_tilesInUseFlag[currLayerId] = x; } 866 Bool getLoopFilterNotAcrossTilesFlag(Int currLayerId) { return m_loopFilterNotAcrossTilesFlag[currLayerId]; } 867 Void setLoopFilterNotAcrossTilesFlag(Int currLayerId, Bool x) { m_loopFilterNotAcrossTilesFlag[currLayerId] = x; } 868 #endif 814 869 #if TILE_BOUNDARY_ALIGNED_FLAG 815 870 Bool getTileBoundariesAlignedFlag(Int currLayerId, Int refLayerId) { return m_tileBoundariesAlignedFlag[currLayerId][refLayerId]; } 816 871 Void setTileBoundariesAlignedFlag(Int currLayerId, Int refLayerId, Bool x) { m_tileBoundariesAlignedFlag[currLayerId][refLayerId] = x; } 817 872 #endif 873 #if VPS_VUI_WPP_NOT_IN_USE__FLAG 874 Bool getWppNotInUseFlag() { return m_wppNotInUseFlag; } 875 Void setWppNotInUseFlag(Bool x); 876 Bool getWppInUseFlag(Int currLayerId) { return m_wppInUseFlag[currLayerId]; } 877 Void setWppInUseFlag(Int currLayerId, Bool x) { m_wppInUseFlag[currLayerId] = x; } 878 #endif 818 879 #if N0160_VUI_EXT_ILP_REF 819 880 Bool getNumIlpRestrictedRefLayers ( ) { return m_numIlpRestrictedRefLayers ;} … … 828 889 Int getMinHorizontalCtuOffsetPlus1 ( Int currLayerId, Int refLayerId ) { return m_minHorizontalCtuOffsetPlus1[currLayerId][refLayerId];} 829 890 Void setMinHorizontalCtuOffsetPlus1 ( Int currLayerId, Int refLayerId, Int val ) { m_minHorizontalCtuOffsetPlus1[currLayerId][refLayerId] = val;} 891 #endif 892 #if VPS_VUI_VIDEO_SIGNAL 893 Bool getVideoSigPresentVpsFlag() { return m_vidSigPresentVpsFlag; } 894 Void setVideoSigPresentVpsFlag(Bool x) { m_vidSigPresentVpsFlag = x; } 895 Int getNumVideoSignalInfo() { return m_vpsVidSigInfo; } 896 Void setNumVideoSignalInfo(Int x) { m_vpsVidSigInfo = x; } 897 Int getVideoSignalInfoIdx(Int idx) { return m_vpsVidSigIdx[idx]; } 898 Void setVideoSignalInfoIdx(Int idx, Int x) { m_vpsVidSigIdx[idx] = x; } 899 Int getVideoVPSFormat(Int idx) { return m_vpsVidFormat[idx]; } 900 Void setVideoVPSFormat(Int idx, Int x) { m_vpsVidFormat[idx] = x; } 901 Bool getVideoFullRangeVpsFlag(Int idx) { return m_vpsFullRangeFlag[idx];} 902 Void setVideoFullRangeVpsFlag(Int idx, Bool x) { m_vpsFullRangeFlag[idx] = x; } 903 Int getColorPrimaries(Int idx) { return m_vpsColorPrimaries[idx]; } 904 Void setColorPrimaries(Int idx, Int x) { m_vpsColorPrimaries[idx] = x; } 905 Int getTransCharacter(Int idx) { return m_vpsTransChar[idx]; } 906 Void setTransCharacter(Int idx, Int x) { m_vpsTransChar[idx] = x; } 907 Int getMaxtrixCoeff(Int idx) { return m_vpsMatCoeff[idx]; } 908 Void setMaxtrixCoeff(Int idx, Int x) { m_vpsMatCoeff[idx] = x; } 830 909 #endif 831 910 #if VPS_VUI_BITRATE_PICRATE … … 850 929 Void setAvgPicRate(Int i, Int j, Int x) { m_avgPicRate[i][j] = x; } 851 930 #endif 852 931 #if O0153_ALT_OUTPUT_LAYER_FLAG 932 Bool getAltOuputLayerFlag() { return m_altOutputLayerFlag; } 933 Void setAltOuputLayerFlag(Bool x) { m_altOutputLayerFlag = x; } 934 #endif 853 935 #if REPN_FORMAT_IN_VPS 854 936 Bool getRepFormatIdxPresentFlag() { return m_repFormatIdxPresentFlag; } … … 883 965 Bool getPhaseAlignFlag() { return m_phaseAlignFlag; } 884 966 Void setPhaseAlignFlag(Bool x) { m_phaseAlignFlag = x; } 967 #endif 968 #if VPS_DPB_SIZE_TABLE 969 Bool getSubLayerFlagInfoPresentFlag(Int i) {return m_subLayerFlagInfoPresentFlag[i]; } 970 Void setSubLayerFlagInfoPresentFlag(Int i, Bool x) {m_subLayerFlagInfoPresentFlag[i] = x; } 971 972 Bool getSubLayerDpbInfoPresentFlag(Int i, Int j) {return m_subLayerDpbInfoPresentFlag[i][j]; } 973 Void setSubLayerDpbInfoPresentFlag(Int i, Int j, Bool x) {m_subLayerDpbInfoPresentFlag[i][j] = x; } 974 975 // For the 0-th output layer set, use the date from the active SPS for base layer. 976 Int getMaxVpsDecPicBufferingMinus1(Int i, Int k, Int j) { assert(i != 0); return m_maxVpsDecPicBufferingMinus1[i][k][j]; } 977 Void setMaxVpsDecPicBufferingMinus1(Int i, Int k, Int j, Int x) { m_maxVpsDecPicBufferingMinus1[i][k][j] = x; } 978 979 Int getMaxVpsNumReorderPics(Int i, Int j) { assert(i != 0); return m_maxVpsNumReorderPics[i][j]; } 980 Void setMaxVpsNumReorderPics(Int i, Int j, Int x) { m_maxVpsNumReorderPics[i][j] = x; } 981 982 Int getMaxVpsLatencyIncreasePlus1(Int i, Int j) { assert(i != 0); return m_maxVpsLatencyIncreasePlus1[i][j]; } 983 Void setMaxVpsLatencyIncreasePlus1(Int i, Int j, Int x) { m_maxVpsLatencyIncreasePlus1[i][j] = x; } 984 985 Int getNumSubDpbs(Int i) { return m_numSubDpbs[i]; } 986 Void setNumSubDpbs(Int i, Int x) { m_numSubDpbs[i] = x; } 885 987 #endif 886 988 #endif //SVC_EXTENSION … … 1185 1287 UInt m_layerId; 1186 1288 1187 #if IL_SL_SIGNALLING_N03711188 TComVPS* m_pVPS;1189 static TComSPS* m_pcSPS[MAX_LAYERS];1190 Bool m_predScalingListFlag;1191 UInt m_scalingListRefLayerId;1192 #endif1193 1194 1289 #if REF_IDX_MFM 1195 1290 #if !M0457_COL_PICTURE_SIGNALING … … 1198 1293 #endif 1199 1294 UInt m_numScaledRefLayerOffsets; 1295 #if O0098_SCALED_REF_LAYER_ID 1296 UInt m_scaledRefLayerId[MAX_LAYERS]; 1297 #endif 1200 1298 Window m_scaledRefLayerWindow[MAX_LAYERS]; 1201 1299 #if REPN_FORMAT_IN_VPS 1202 1300 Bool m_updateRepFormatFlag; 1301 #if O0096_REP_FORMAT_INDEX 1302 UInt m_updateRepFormatIndex; 1303 #endif 1304 #endif 1305 #if SCALINGLIST_INFERRING 1306 Bool m_inferScalingListFlag; 1307 UInt m_scalingListRefLayerId; 1203 1308 #endif 1204 1309 #endif //SVC_EXTENSION … … 1322 1427 Void setScalingListPresentFlag( Bool b ) { m_scalingListPresentFlag = b; } 1323 1428 1324 #if IL_SL_SIGNALLING_N0371 1325 Bool getPredScalingListFlag() { return m_predScalingListFlag; } 1326 Void setPredScalingListFlag( Bool b ) { m_predScalingListFlag = b; } 1327 UInt getScalingListRefLayerId() { return m_scalingListRefLayerId; } 1328 Void setScalingListRefLayerId( UInt b ) { m_scalingListRefLayerId = b; } 1329 1330 TComVPS* getVPS() { return m_pVPS; } 1331 Void setVPS( TComVPS* vps ) { m_pVPS = vps; } 1332 static TComSPS* getSPS(UInt layerId) { return m_pcSPS[layerId]; } 1333 static Void setSPS(UInt layerId, TComSPS* sps) { m_pcSPS[layerId] = sps; } 1334 #endif 1335 1429 #if SCALINGLIST_INFERRING 1430 Void setScalingList( TComScalingList *scalingList ) { m_scalingList = scalingList; } 1431 #else 1336 1432 Void setScalingList ( TComScalingList *scalingList); 1433 #endif 1337 1434 TComScalingList* getScalingList () { return m_scalingList; } //!< get ScalingList class pointer in SPS 1338 1435 … … 1380 1477 UInt getNumScaledRefLayerOffsets() { return m_numScaledRefLayerOffsets; } 1381 1478 Void setNumScaledRefLayerOffsets(Int x) { m_numScaledRefLayerOffsets = x; } 1479 #if O0098_SCALED_REF_LAYER_ID 1480 UInt getScaledRefLayerId(Int x) { return m_scaledRefLayerId[x]; } 1481 Void setScaledRefLayerId(Int x, UInt id) { m_scaledRefLayerId[x] = id; } 1482 Window& getScaledRefLayerWindowForLayer( Int layerId ); 1483 #endif 1382 1484 Window& getScaledRefLayerWindow( Int x ) { return m_scaledRefLayerWindow[x]; } 1383 1485 #if REPN_FORMAT_IN_VPS 1384 1486 Bool getUpdateRepFormatFlag() { return m_updateRepFormatFlag; } 1385 1487 Void setUpdateRepFormatFlag(Bool x) { m_updateRepFormatFlag = x; } 1488 #if O0096_REP_FORMAT_INDEX 1489 Int getUpdateRepFormatIndex() { return m_updateRepFormatIndex; } 1490 Void setUpdateRepFormatIndex(UInt index) { m_updateRepFormatIndex = index; } 1491 #endif 1492 #endif 1493 #if SCALINGLIST_INFERRING 1494 Bool getInferScalingListFlag() { return m_inferScalingListFlag; } 1495 UInt getScalingListRefLayerId() { return m_scalingListRefLayerId; } 1496 Void setInferScalingListFlag( Bool flag ) { m_inferScalingListFlag = flag; } 1497 Void setScalingListRefLayerId( UInt layerId ) { m_scalingListRefLayerId = layerId; } 1386 1498 #endif 1387 1499 #endif //SVC_EXTENSION … … 1468 1580 Int m_deblockingFilterTcOffsetDiv2; //< tc offset for deblocking filter 1469 1581 Bool m_scalingListPresentFlag; 1470 1471 #if SVC_EXTENSION1472 UInt m_layerId;1473 1474 #if IL_SL_SIGNALLING_N03711475 static TComPPS* m_pcPPS[MAX_LAYERS];1476 Bool m_predScalingListFlag;1477 UInt m_scalingListRefLayerId;1478 #endif1479 1480 #endif1481 1482 1582 TComScalingList* m_scalingList; //!< ScalingList class pointer 1483 1484 1583 Bool m_listsModificationPresentFlag; 1485 1584 UInt m_log2ParallelMergeLevelMinus2; 1486 1585 Int m_numExtraSliceHeaderBits; 1586 1587 #if SVC_EXTENSION 1588 #if SCALINGLIST_INFERRING 1589 UInt m_layerId; 1590 Bool m_inferScalingListFlag; 1591 UInt m_scalingListRefLayerId; 1592 #endif 1593 #endif 1487 1594 1488 1595 public: … … 1596 1703 Void setScalingListPresentFlag( Bool b ) { m_scalingListPresentFlag = b; } 1597 1704 1598 #if IL_SL_SIGNALLING_N0371 1599 Void setLayerId(UInt layerId) { m_layerId = layerId; } 1705 #if SCALINGLIST_INFERRING 1600 1706 UInt getLayerId() { return m_layerId; } 1601 1602 Bool get PredScalingListFlag() { return m_predScalingListFlag;}1603 Void setPredScalingListFlag( Bool b ) { m_predScalingListFlag = b;}1604 UInt getScalingListRefLayerId() { return m_scalingListRefLayerId; }1605 Void setScalingListRefLayerId( UInt b ) { m_scalingListRefLayerId = b;}1606 1607 static TComPPS* getPPS(UInt layerId) { return m_pcPPS[layerId]; } 1608 static Void setPPS(UInt layerId, TComPPS* pps) { m_pcPPS[layerId] = pps; } 1609 #endif 1610 1707 Void setLayerId( UInt layerId ) { m_layerId = layerId; } 1708 Bool getInferScalingListFlag() { return m_inferScalingListFlag; } 1709 UInt getScalingListRefLayerId() { return m_scalingListRefLayerId; } 1710 Void setInferScalingListFlag( Bool flag ) { m_inferScalingListFlag = flag; } 1711 Void setScalingListRefLayerId( UInt layerId ) { m_scalingListRefLayerId = layerId; } 1712 #endif 1713 1714 #if SCALINGLIST_INFERRING 1715 Void setScalingList( TComScalingList *scalingList ) { m_scalingList = scalingList; } 1716 #else 1611 1717 Void setScalingList ( TComScalingList *scalingList); 1718 #endif 1612 1719 TComScalingList* getScalingList () { return m_scalingList; } //!< get ScalingList class pointer in PPS 1613 1720 Bool getListsModificationPresentFlag () { return m_listsModificationPresentFlag; } … … 1705 1812 UInt m_maxNumMergeCand; 1706 1813 1707 #if SAO_CHROMA_LAMBDA 1708 Double m_dLambdaLuma; 1709 Double m_dLambdaChroma; 1710 #else 1711 Double m_dLambda; 1712 #endif 1814 Double m_lambdas[3]; 1713 1815 1714 1816 Bool m_abEqualRef [2][MAX_NUM_REF][MAX_NUM_REF]; … … 1780 1882 #endif 1781 1883 Bool m_bDiscardableFlag; 1884 #if O0149_CROSS_LAYER_BLA_FLAG 1885 Bool m_bCrossLayerBLAFlag; 1886 #endif 1782 1887 #endif //SVC_EXTENSION 1783 1888 … … 1819 1924 Int getRPSidx () { return m_iBDidx; } 1820 1925 Int getPrevTid0POC () { return m_prevTid0POC; } 1926 #if PREVTID0_POC_RESET 1927 Void adjustPrevTid0POC (Int adj) { m_prevTid0POC=m_prevTid0POC-adj; } 1928 #endif 1821 1929 TComRefPicListModification* getRefPicListModification() { return &m_RefPicListModification; } 1822 1930 Void setLastIDR(Int iIDRPOC) { m_iLastIDR = iIDRPOC; } … … 1866 1974 Bool isIRAP () const { return (getNalUnitType() >= 16) && (getNalUnitType() <= 23); } 1867 1975 Void checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic); 1976 #if NO_CLRAS_OUTPUT_FLAG 1977 Void decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag); 1978 #else 1868 1979 Void decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic); 1980 #endif 1869 1981 Void setSliceType ( SliceType e ) { m_eSliceType = e; } 1870 1982 Void setSliceQp ( Int i ) { m_iSliceQp = i; } … … 1886 1998 Void setDepth ( Int iDepth ) { m_iDepth = iDepth; } 1887 1999 1888 #if FIX10711889 2000 #if SVC_EXTENSION 1890 2001 Void setRefPicList ( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr = false, TComPic** ilpPic = NULL ); 1891 2002 #else 1892 2003 Void setRefPicList ( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr = false ); 1893 #endif1894 #else1895 Void setRefPicList ( TComList<TComPic*>& rcListPic );1896 2004 #endif 1897 2005 Void setRefPOCList (); … … 1905 2013 Bool isInterP () { return m_eSliceType == P_SLICE; } 1906 2014 1907 #if SAO_CHROMA_LAMBDA 1908 Void setLambda( Double d, Double e ) { m_dLambdaLuma = d; m_dLambdaChroma = e;} 1909 Double getLambdaLuma() { return m_dLambdaLuma; } 1910 Double getLambdaChroma() { return m_dLambdaChroma; } 1911 #else 1912 Void setLambda( Double d ) { m_dLambda = d; } 1913 Double getLambda() { return m_dLambda; } 1914 #endif 2015 Void setLambdas ( const Double lambdas[3] ) { for (Int component = 0; component < 3; component++) m_lambdas[component] = lambdas[component]; } 2016 const Double* getLambdas() const { return m_lambdas; } 1915 2017 1916 2018 Void initEqualRef(); … … 1939 2041 Bool isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic ); 1940 2042 Int checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess = 0); 1941 #if FIX10711942 2043 Void createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP); 1943 #else1944 Void createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet);1945 #endif1946 2044 1947 2045 Void setMaxNumMergeCand (UInt val ) { m_maxNumMergeCand = val; } … … 2001 2099 Void setScalingList ( TComScalingList* scalingList ) { m_scalingList = scalingList; } 2002 2100 TComScalingList* getScalingList () { return m_scalingList; } 2003 2004 #if IL_SL_SIGNALLING_N03712005 Void setDefaultScalingList ( UInt m_layerId );2006 #else2007 2101 Void setDefaultScalingList (); 2008 #endif2009 2010 2102 Bool checkDefaultScalingList (); 2011 2103 Void setCabacInitFlag ( Bool val ) { m_cabacInitFlag = val; } //!< set CABAC initial flag … … 2022 2114 2023 2115 #if SVC_EXTENSION 2024 VoidsetBaseColPic ( TComList<TComPic*>& rcListPic , UInt refLayerIdc );2116 Bool setBaseColPic ( TComList<TComPic*>& rcListPic , UInt refLayerIdc ); 2025 2117 Void setBaseColPic (UInt refLayerIdc, TComPic* p) { m_pcBaseColPic[refLayerIdc] = p; } 2026 2118 TComPic* getBaseColPic (UInt refLayerIdc) { return m_pcBaseColPic[refLayerIdc]; } … … 2099 2191 Bool getDiscardableFlag () { return m_bDiscardableFlag; } 2100 2192 Void setDiscardableFlag (Bool b) { m_bDiscardableFlag = b; } 2193 #if O0149_CROSS_LAYER_BLA_FLAG 2194 Bool getCrossLayerBLAFlag () { return m_bCrossLayerBLAFlag; } 2195 Void setCrossLayerBLAFlag (Bool b) { m_bCrossLayerBLAFlag = b; } 2196 #endif 2101 2197 2102 2198 #if RPL_INIT_N0316_N0082 -
trunk/source/Lib/TLibCommon/TComTrQuant.cpp
r442 r540 54 54 { 55 55 iNNZbeforePos0 = 0; 56 d64CodedLevelandDist = 0;57 d64UncodedDist = 0;58 d64SigCost = 0;59 d64SigCost_0 = 0;56 d64CodedLevelandDist = 0; 57 d64UncodedDist = 0; 58 d64SigCost = 0; 59 d64SigCost_0 = 0; 60 60 } 61 61 #endif … … 1944 1944 Int64 costUp = rdFactor * ( - deltaU[uiBlkPos] ) + rateIncUp[uiBlkPos] ; 1945 1945 Int64 costDown = rdFactor * ( deltaU[uiBlkPos] ) + rateIncDown[uiBlkPos] 1946 - ( abs(piDstCoeff[uiBlkPos])==1?((1<<15)+sigRateDelta[uiBlkPos]):0);1946 - ((abs(piDstCoeff[uiBlkPos]) == 1) ? sigRateDelta[uiBlkPos] : 0); 1947 1947 1948 1948 if(lastCG==1 && lastNZPosInCG==n && abs(piDstCoeff[uiBlkPos])==1) … … 2163 2163 { 2164 2164 Double dErr = Double( lLevelDouble - ( uiAbsLevel << iQBits ) ); 2165 Double dCurrCost = dErr * dErr * dTemp + xGetIC RateCost( uiAbsLevel, ui16CtxNumOne, ui16CtxNumAbs, ui16AbsGoRice, c1Idx, c2Idx);2165 Double dCurrCost = dErr * dErr * dTemp + xGetICost(xGetICRate( uiAbsLevel, ui16CtxNumOne, ui16CtxNumAbs, ui16AbsGoRice, c1Idx, c2Idx )); 2166 2166 dCurrCost += dCurrCostSig; 2167 2167 … … 2184 2184 * \returns cost of given absolute transform level 2185 2185 */ 2186 __inline Double TComTrQuant::xGetICRateCost( UInt uiAbsLevel,2186 __inline Int TComTrQuant::xGetICRate ( UInt uiAbsLevel, 2187 2187 UShort ui16CtxNumOne, 2188 2188 UShort ui16CtxNumAbs, … … 2192 2192 ) const 2193 2193 { 2194 Double iRate = xGetIEPRate();2194 Int iRate = Int(xGetIEPRate()); 2195 2195 UInt baseLevel = (c1Idx < C1FLAG_NUMBER)? (2 + (c2Idx < C2FLAG_NUMBER)) : 1; 2196 2196 … … 2236 2236 else 2237 2237 { 2238 assert (0); 2239 } 2240 return xGetICost( iRate ); 2241 } 2242 2243 __inline Int TComTrQuant::xGetICRate ( UInt uiAbsLevel, 2244 UShort ui16CtxNumOne, 2245 UShort ui16CtxNumAbs, 2246 UShort ui16AbsGoRice 2247 , UInt c1Idx, 2248 UInt c2Idx 2249 ) const 2250 { 2251 Int iRate = 0; 2252 UInt baseLevel = (c1Idx < C1FLAG_NUMBER)? (2 + (c2Idx < C2FLAG_NUMBER)) : 1; 2253 2254 if ( uiAbsLevel >= baseLevel ) 2255 { 2256 UInt uiSymbol = uiAbsLevel - baseLevel; 2257 UInt uiMaxVlc = g_auiGoRiceRange[ ui16AbsGoRice ]; 2258 Bool bExpGolomb = ( uiSymbol > uiMaxVlc ); 2259 2260 if( bExpGolomb ) 2261 { 2262 uiAbsLevel = uiSymbol - uiMaxVlc; 2263 Int iEGS = 1; for( UInt uiMax = 2; uiAbsLevel >= uiMax; uiMax <<= 1, iEGS += 2 ); 2264 iRate += iEGS << 15; 2265 uiSymbol = min<UInt>( uiSymbol, ( uiMaxVlc + 1 ) ); 2266 } 2267 2268 UShort ui16PrefLen = UShort( uiSymbol >> ui16AbsGoRice ) + 1; 2269 UShort ui16NumBins = min<UInt>( ui16PrefLen, g_auiGoRicePrefixLen[ ui16AbsGoRice ] ) + ui16AbsGoRice; 2270 2271 iRate += ui16NumBins << 15; 2272 2273 if (c1Idx < C1FLAG_NUMBER) 2274 { 2275 iRate += m_pcEstBitsSbac->m_greaterOneBits[ ui16CtxNumOne ][ 1 ]; 2276 2277 if (c2Idx < C2FLAG_NUMBER) 2278 { 2279 iRate += m_pcEstBitsSbac->m_levelAbsBits[ ui16CtxNumAbs ][ 1 ]; 2280 } 2281 } 2282 } 2283 else 2284 if( uiAbsLevel == 0 ) 2285 { 2286 return 0; 2287 } 2288 else if( uiAbsLevel == 1 ) 2289 { 2290 iRate += m_pcEstBitsSbac->m_greaterOneBits[ ui16CtxNumOne ][ 0 ]; 2291 } 2292 else if( uiAbsLevel == 2 ) 2293 { 2294 iRate += m_pcEstBitsSbac->m_greaterOneBits[ ui16CtxNumOne ][ 1 ]; 2295 iRate += m_pcEstBitsSbac->m_levelAbsBits[ ui16CtxNumAbs ][ 0 ]; 2296 } 2297 else 2298 { 2299 assert(0); 2238 iRate = 0; 2300 2239 } 2301 2240 return iRate; … … 2494 2433 /** set flat matrix value to quantized coefficient 2495 2434 */ 2496 #if IL_SL_SIGNALLING_N03712497 Void TComTrQuant::setFlatScalingList( UInt m_layerId )2498 #else2499 2435 Void TComTrQuant::setFlatScalingList() 2500 #endif2501 2436 { 2502 2437 UInt size,list; … … 2507 2442 for(list = 0; list < g_scalingListNum[size]; list++) 2508 2443 { 2509 #if IL_SL_SIGNALLING_N03712510 ref_scalingListDC[m_layerId][size][list] = SCALING_LIST_DC;2511 for(UInt i=0; i<MAX_MATRIX_COEF_NUM; i++)2512 {2513 ref_scalingListCoef[m_layerId][size][list][i] = SCALING_LIST_DC;2514 }2515 #endif2516 2517 2444 for(qp=0;qp<SCALING_LIST_REM_NUM;qp++) 2518 2445 { -
trunk/source/Lib/TLibCommon/TComTrQuant.h
r442 r540 150 150 151 151 #if RDOQ_CHROMA_LAMBDA 152 Void setLambda (Double dLambdaLuma, Double dLambdaChroma) { m_dLambdaLuma = dLambdaLuma; m_dLambdaChroma = dLambdaChroma; }153 Void selectLambda(TextType eTType) { m_dLambda = (eTType == TEXT_LUMA) ? m_ dLambdaLuma : m_dLambdaChroma; }152 Void setLambdas ( const Double lambdas[3] ) { for (Int component = 0; component < 3; component++) m_lambdas[component] = lambdas[component]; } 153 Void selectLambda(TextType eTType) { m_dLambda = (eTType == TEXT_LUMA) ? m_lambdas[0] : ((eTType == TEXT_CHROMA_U) ? m_lambdas[1] : m_lambdas[2]); } 154 154 #else 155 155 Void setLambda(Double dLambda) { m_dLambda = dLambda;} … … 181 181 Void setUseScalingList ( Bool bUseScalingList){ m_scalingListEnabledFlag = bUseScalingList; }; 182 182 Bool getUseScalingList (){ return m_scalingListEnabledFlag; }; 183 184 #if IL_SL_SIGNALLING_N0371185 Void setFlatScalingList ( UInt m_layerId );186 #else187 183 Void setFlatScalingList (); 188 #endif189 190 184 Void xsetFlatScalingList ( UInt list, UInt size, UInt qp); 191 185 Void xSetScalingListEnc ( TComScalingList *scalingList, UInt list, UInt size, UInt qp); … … 213 207 QpParam m_cQP; 214 208 #if RDOQ_CHROMA_LAMBDA 215 Double m_dLambdaLuma; 216 Double m_dLambdaChroma; 209 Double m_lambdas[3]; 217 210 #endif 218 211 Double m_dLambda; … … 279 272 Double dTemp, 280 273 Bool bLast ) const; 281 __inline Double xGetICRateCost ( UInt uiAbsLevel,282 UShort ui16CtxNumOne,283 UShort ui16CtxNumAbs,284 UShort ui16AbsGoRice285 , UInt c1Idx,286 UInt c2Idx287 ) const;288 274 __inline Int xGetICRate ( UInt uiAbsLevel, 289 275 UShort ui16CtxNumOne, -
trunk/source/Lib/TLibCommon/TypeDef.h
r494 r540 51 51 #define O0194_JOINT_US_BITSHIFT 1 ///< JCTVC-O0194: Joint Upsampling and bit-shift 52 52 #endif 53 #define O0194_WEIGHTED_PREDICTION_CGS 1///< JCTVC-O0194: Weighted prediciton for color gamut scalability53 #define O0194_WEIGHTED_PREDICTION_CGS 0 ///< JCTVC-O0194: Weighted prediciton for color gamut scalability 54 54 #define MFM_ENCCONSTRAINT 1 ///< JCTVC-O0216: Encoder constraint for motion field mapping 55 55 #define VPS_NUH_LAYER_ID 1 ///< JCTVC-N0085: Assert that the nuh_layer_id of VPS NAL unit should be 0 … … 57 57 #define ALIGN_TSA_STSA_PICS 1 ///< JCTVC-N0084: Alignment of TSA and STSA pictures across AU. 58 58 #define REPN_FORMAT_IN_VPS 1 ///< JCTVC-N0092: Signal represenation format (spatial resolution, bit depth, colour format) in the VPS 59 #if REPN_FORMAT_IN_VPS 60 #define REPN_FORMAT_CONTROL_FLAG 1 ///< JCTVC-O0179: Add control flag in representation format to control sending of chroma and bitdepth parameters 61 #endif 59 62 #define TIMING_INFO_NONZERO_LAYERID_SPS 1 ///< JCTVC-N0085: Semantics of vui_timing_info_present_flag to always set that flag to zero for non-zero layer ID SPS 60 63 #define RPL_INIT_N0316_N0082 1 ///< JCTVC-N0316, JCTVC-N0082: initial reference picture list construction 61 64 62 #define IL_SL_SIGNALLING_N0371 0///< JCTVC-N0371: inter-layer scaling list65 #define SCALINGLIST_INFERRING 1 ///< JCTVC-N0371: inter-layer scaling list 63 66 #define M0463_VUI_EXT_ILP_REF 0 ///< JCTVC-M0463: VUI extension inter-layer dependency offset signalling 64 67 #define SPS_EXTENSION 1 ///< Define sps_extension() syntax structure 68 #if SPS_EXTENSION 69 #define O0142_CONDITIONAL_SPS_EXTENSION 1 ///< JCTVC-O0142: Conditional SPS extension 70 #endif 65 71 #define VERT_MV_CONSTRAINT 1 ///< Vertical MV component constraint flag 66 72 #define SCALABILITY_MASK_E0104 1 ///< JCT3V-E0104: scalability mask for depth 67 73 #define LAYER_CTB 0 ///< enable layer-specific CTB structure 74 #if POC_RESET_FLAG 75 #define PREVTID0_POC_RESET 1 ///< JCTVC-O0117 Modification of the PicOrderCntVal of prevTid0Pic 76 #define POC_RESET_RPS 1 ///< JCTVC-O0117 Modification to the decoding process for rps 77 #endif 68 78 69 79 #define ILP_SSH_SIG 1 ///< JCTVC-N0195 proposal 2, JCTVC-N0118: add presence flag in VPS ext to condition inter-layer prediction signaling in slice segment header … … 86 96 87 97 #if VPS_VUI 98 #define VPS_VUI_TILES_NOT_IN_USE__FLAG 1 ///< JCTVC-O0226: VPS VUI flag to indicate tile not in use 99 #define VPS_VUI_WPP_NOT_IN_USE__FLAG 1 ///< JCTVC-O0226: VPS VUI flag to indicate tile not in use 88 100 #define TILE_BOUNDARY_ALIGNED_FLAG 1 ///< JCTVC-N0160/JCTVC-N0199 proposal 2 variant 2: VPS VUI flag to indicate tile boundary alignment 89 101 #define N0160_VUI_EXT_ILP_REF 1 ///< VUI extension inter-layer dependency offset signalling 90 102 #define VPS_VUI_BITRATE_PICRATE 1 ///< JCTVC-N0085: Signal bit rate and picture in VPS VUI 103 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 104 #define HIGHER_LAYER_IRAP_SKIP_FLAG 1 ///< JCTVC-O0199: Indication that higher layer IRAP picture uses skip blocks only 105 #endif 106 #define VPS_VUI_VIDEO_SIGNAL 1 ///< JCTVC-O0118 video signal information 91 107 #endif //VPS_VUI 92 108 … … 127 143 #define N0120_MAX_TID_REF_CFG 1 ///< set max_tid_il_ref_pics_plus1 and max_tid_ref_present_flag in the config. file (configuration setting) 128 144 #define O0225_MAX_TID_FOR_REF_LAYERS 1 145 #define O0225_TID_BASED_IL_RPS_DERIV 1 146 147 #define VPS_TSLAYERS 1 ///< JCTVC-O0120 signal max temporal sub-layers for each layer 148 #define TSLAYERS_IL_RPS 1 ///< JCTVC-O0120 IL RPS based on max temporal sub-layers 129 149 #endif 130 150 #if REF_IDX_MFM … … 139 159 #define M0457_IL_SAMPLE_PRED_ONLY_FLAG 0 ///< shall be 0, JCTVC-N0107 140 160 #endif 161 162 #define O0223_PICTURE_TYPES_ALIGN_FLAG 1 ///< a flag to indicatate whether picture types are aligned across layers. 141 163 142 164 #define N0147_IRAP_ALIGN_FLAG 1 ///< a flag to indicatate whether IRAPs are aligned across layers … … 166 188 #define SHM_FIX7 1 ///< fix for SHVC WD ticket #7 167 189 190 #define O0092_0094_DEPENDENCY_CONSTRAINT 1 ///< JCTVC-O0092: constraint on the layer_id of SPS/PPS 191 #if O0092_0094_DEPENDENCY_CONSTRAINT 192 #define MAX_REF_LAYERS 7 193 #endif 194 #define O0096_REP_FORMAT_INDEX 1 ///< JCTVC-O0096: identify SPS rep_format() with an index into the lists of formats in VPS extension. 195 #define O0096_DEFAULT_DEPENDENCY_TYPE 1 ///< JCTVC-O0096: specify default dependency type for all direct reference layers 196 197 #define RESAMPLING_CONSTRAINT_BUG_FIX 1 198 #define O0098_SCALED_REF_LAYER_ID 1 ///< JCTVC-O0098: signal scaled reference id 199 200 #define O0153_ALT_OUTPUT_LAYER_FLAG 1 ///< JCTVC-O0153: alt output layer flag 201 202 #define VPS_DPB_SIZE_TABLE 1 ///< JCTVC-O0217: DPB operations: signaling DPB-related parameters 203 #if VPS_DPB_SIZE_TABLE 204 #define OUTPUT_LAYER_SET_INDEX 1 ///< JCTVC-O0217: DPB operations: Inference/input of output layer set index 205 #if OUTPUT_LAYER_SET_INDEX 206 #define USE_DPB_SIZE_TABLE 1 ///< JCTVC-O0217: DPB operations: Use signaled DPB-size table parameters in the decoder 207 #endif 208 #endif 209 210 #define NO_CLRAS_OUTPUT_FLAG 1 211 #define O0149_CROSS_LAYER_BLA_FLAG 1 ///< JCTVC-O0149: signal cross_layer_bla_flag in slice header 212 168 213 #else 169 214 #define SYNTAX_OUTPUT 0 … … 174 219 //! \{ 175 220 176 #define FIX1071 1 ///< fix for issue #1071 221 #define HM_CLEANUP_SAO 1 ///< JCTVC-N0230, 1) three SAO encoder-only software bugfixes. 2) new SAO implementation without picture quadtree, fine-grained slice legacies, and other redundancies. 222 #if HM_CLEANUP_SAO 223 #define SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1 224 #endif 177 225 178 226 #define MAX_NUM_PICS_IN_SOP 1024 … … 184 232 #define MAX_VPS_NUM_SCALABILITY_TYPES 16 185 233 #endif 234 #define MAX_VPS_OP_LAYER_SETS_PLUS1 3 186 235 #if VPS_RENAME 187 236 #define MAX_VPS_LAYER_SETS_PLUS1 1024 … … 192 241 #define MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 1 193 242 #endif 194 #define RATE_CONTROL_LAMBDA_DOMAIN 1 ///< JCTVC-K0103, rate control by R-lambda model195 #define M0036_RC_IMPROVEMENT 1 ///< JCTVC-M0036, improvement for R-lambda model based rate control196 #define TICKET_1090_FIX 1197 198 #define RC_FIX 1 /// suggested fix for M0036199 #define RATE_CONTROL_INTRA 1 ///< JCTVC-M0257, rate control for intra200 243 201 244 #define MAX_CPB_CNT 32 ///< Upper bound of (cpb_cnt_minus1 + 1) … … 216 259 #define C1FLAG_NUMBER 8 // maximum number of largerThan1 flag coded in one chunk : 16 in HM5 217 260 #define C2FLAG_NUMBER 1 // maximum number of largerThan2 flag coded in one chunk: 16 in HM5 218 261 #if !HM_CLEANUP_SAO 219 262 #define REMOVE_SAO_LCU_ENC_CONSTRAINTS_3 1 ///< disable the encoder constraint that conditionally disable SAO for chroma for entire slice in interleaved mode 220 263 #endif 221 264 #define SAO_ENCODING_CHOICE 1 ///< I0184: picture early termination 222 265 #if SAO_ENCODING_CHOICE … … 232 275 #define MAX_NUM_PPS 64 233 276 234 #define WEIGHTED_CHROMA_DISTORTION 1 ///< F386: weighting of chroma for RDO235 277 #define RDOQ_CHROMA_LAMBDA 1 ///< F386: weighting of chroma for RDOQ 236 #define SAO_CHROMA_LAMBDA 1 ///< F386: weighting of chroma for SAO237 278 238 279 #define MIN_SCAN_POS_CROSS 4 … … 248 289 #define LEVEL_RANGE 30 ///< G382: max coefficient level in statistics collection 249 290 #endif 250 251 #define NS_HAD 0252 291 253 292 #define HHI_RQT_INTRA_SPEEDUP 1 ///< tests one best mode with full rqt … … 316 355 #define AMP_MRG 1 ///< encoder only force merge for AMP partition (no motion search for AMP) 317 356 #endif 318 319 #define SCALING_LIST_OUTPUT_RESULT 0 //JCTVC-G880/JCTVC-G1016 quantization matrices320 357 321 358 #define CABAC_INIT_PRESENT_FLAG 1 … … 377 414 }; 378 415 416 #if HM_CLEANUP_SAO 417 enum SAOComponentIdx 418 { 419 SAO_Y =0, 420 SAO_Cb, 421 SAO_Cr, 422 NUM_SAO_COMPONENTS 423 }; 424 425 enum SAOMode //mode 426 { 427 SAO_MODE_OFF = 0, 428 SAO_MODE_NEW, 429 SAO_MODE_MERGE, 430 NUM_SAO_MODES 431 }; 432 433 enum SAOModeMergeTypes 434 { 435 SAO_MERGE_LEFT =0, 436 SAO_MERGE_ABOVE, 437 NUM_SAO_MERGE_TYPES 438 }; 439 440 441 enum SAOModeNewTypes 442 { 443 SAO_TYPE_START_EO =0, 444 SAO_TYPE_EO_0 = SAO_TYPE_START_EO, 445 SAO_TYPE_EO_90, 446 SAO_TYPE_EO_135, 447 SAO_TYPE_EO_45, 448 449 SAO_TYPE_START_BO, 450 SAO_TYPE_BO = SAO_TYPE_START_BO, 451 452 NUM_SAO_NEW_TYPES 453 }; 454 #define NUM_SAO_EO_TYPES_LOG2 2 455 456 enum SAOEOClasses 457 { 458 SAO_CLASS_EO_FULL_VALLEY = 0, 459 SAO_CLASS_EO_HALF_VALLEY = 1, 460 SAO_CLASS_EO_PLAIN = 2, 461 SAO_CLASS_EO_HALF_PEAK = 3, 462 SAO_CLASS_EO_FULL_PEAK = 4, 463 NUM_SAO_EO_CLASSES, 464 }; 465 466 467 #define NUM_SAO_BO_CLASSES_LOG2 5 468 enum SAOBOClasses 469 { 470 //SAO_CLASS_BO_BAND0 = 0, 471 //SAO_CLASS_BO_BAND1, 472 //SAO_CLASS_BO_BAND2, 473 //... 474 //SAO_CLASS_BO_BAND31, 475 476 NUM_SAO_BO_CLASSES = (1<<NUM_SAO_BO_CLASSES_LOG2), 477 }; 478 #define MAX_NUM_SAO_CLASSES 32 //(NUM_SAO_EO_GROUPS > NUM_SAO_BO_GROUPS)?NUM_SAO_EO_GROUPS:NUM_SAO_BO_GROUPS 479 480 struct SAOOffset 481 { 482 Int modeIdc; //NEW, MERGE, OFF 483 Int typeIdc; //NEW: EO_0, EO_90, EO_135, EO_45, BO. MERGE: left, above 484 Int typeAuxInfo; //BO: starting band index 485 Int offset[MAX_NUM_SAO_CLASSES]; 486 487 SAOOffset(); 488 ~SAOOffset(); 489 Void reset(); 490 491 const SAOOffset& operator= (const SAOOffset& src); 492 }; 493 494 struct SAOBlkParam 495 { 496 497 SAOBlkParam(); 498 ~SAOBlkParam(); 499 Void reset(); 500 const SAOBlkParam& operator= (const SAOBlkParam& src); 501 SAOOffset& operator[](Int compIdx){ return offsetParam[compIdx];} 502 private: 503 SAOOffset offsetParam[NUM_SAO_COMPONENTS]; 504 505 }; 506 507 508 #else 379 509 #define NUM_DOWN_PART 4 380 510 … … 448 578 ~SAOParam(); 449 579 }; 450 580 #endif 451 581 /// parameters for deblocking filter 452 582 typedef struct _LFCUParam -
trunk/source/Lib/TLibDecoder/NALread.cpp
r313 r540 126 126 else 127 127 { 128 assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_T LA_R128 assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_R 129 129 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N 130 130 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R -
trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp
r494 r540 290 290 } 291 291 } 292 293 #if SCALINGLIST_INFERRING 294 if( pcPPS->getLayerId() > 0 ) 295 { 296 READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); 297 pcPPS->setInferScalingListFlag( uiCode ); 298 } 299 300 if( pcPPS->getInferScalingListFlag() ) 301 { 302 READ_UVLC( uiCode, "pps_scaling_list_ref_layer_id" ); pcPPS->setScalingListRefLayerId( uiCode ); 303 304 // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive 305 assert( pcPPS->getScalingListRefLayerId() <= 62 ); 306 307 pcPPS->setScalingListPresentFlag( false ); 308 } 309 else 310 { 311 #endif 312 292 313 READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); 293 314 294 #if IL_SL_SIGNALLING_N0371295 pcPPS->setPPS( pcPPS->getLayerId(), pcPPS );296 #endif297 298 315 if(pcPPS->getScalingListPresentFlag ()) 299 316 { 300 #if IL_SL_SIGNALLING_N0371301 pcPPS->getScalingList()->setLayerId( pcPPS->getLayerId() );302 303 if( pcPPS->getLayerId() > 0 )304 {305 READ_FLAG( uiCode, "pps_pred_scaling_list_flag" ); pcPPS->setPredScalingListFlag( uiCode ? true : false );306 pcPPS->getScalingList()->setPredScalingListFlag( pcPPS->getPredScalingListFlag() );307 308 if( pcPPS->getPredScalingListFlag() )309 {310 READ_UVLC ( uiCode, "scaling_list_pps_ref_layer_id" ); pcPPS->setScalingListRefLayerId( uiCode );311 312 // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive313 assert( /*pcPPS->getScalingListRefLayerId() >= 0 &&*/ pcPPS->getScalingListRefLayerId() <= 62 );314 315 // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of pps_scaling_list_ref_layer_id shall be greater than 0316 if( pcPPS->getSPS()->getVPS()->getAvcBaseLayerFlag() )317 {318 assert( pcPPS->getScalingListRefLayerId() > 0 );319 }320 321 // It is a requirement of bitstream conformance that, when a PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and322 // pps_infer_scaling_list_flag in the PPS is equal to 1, pps_infer_scaling_list_flag shall be equal to 0 for the PPS that is active for the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id323 assert( pcPPS->getPPS( pcPPS->getScalingListRefLayerId() )->getPredScalingListFlag() == false );324 325 // It is a requirement of bitstream conformance that, when a PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB,326 // the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB327 assert( pcPPS->getSPS()->getVPS()->getScalingListLayerDependency( pcPPS->getLayerId(), pcPPS->getScalingListRefLayerId() ) == true );328 329 pcPPS->getScalingList()->setScalingListRefLayerId( pcPPS->getScalingListRefLayerId() );330 parseScalingList( pcPPS->getScalingList() );331 }332 else333 {334 parseScalingList( pcPPS->getScalingList() );335 }336 }337 else338 {339 parseScalingList( pcPPS->getScalingList() );340 }341 #else342 317 parseScalingList( pcPPS->getScalingList() ); 343 #endif 344 } 318 } 319 320 #if SCALINGLIST_INFERRING 321 } 322 #endif 345 323 346 324 READ_FLAG( uiCode, "lists_modification_present_flag"); … … 563 541 pcSPS->setTemporalIdNestingFlag( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getTemporalNestingFlag() ); 564 542 } 565 #if IL_SL_SIGNALLING_N0371566 pcSPS->setVPS( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId()) );567 pcSPS->setSPS( pcSPS->getLayerId(), pcSPS );568 #endif569 543 #endif 570 544 if ( pcSPS->getMaxTLayers() == 1 ) … … 599 573 pcSPS->setUpdateRepFormatFlag( true ); 600 574 } 575 #if O0096_REP_FORMAT_INDEX 576 if( pcSPS->getLayerId() == 0 ) 577 #else 601 578 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 579 #endif 602 580 { 603 581 #endif … … 619 597 #if REPN_FORMAT_IN_VPS 620 598 } 599 #if O0096_REP_FORMAT_INDEX 600 else if ( pcSPS->getUpdateRepFormatFlag() ) 601 { 602 READ_CODE(8, uiCode, "update_rep_format_index"); 603 pcSPS->setUpdateRepFormatIndex(uiCode); 604 } 605 #endif 621 606 #endif 622 607 READ_FLAG( uiCode, "conformance_window_flag"); … … 637 622 } 638 623 #if REPN_FORMAT_IN_VPS 624 #if O0096_REP_FORMAT_INDEX 625 if( pcSPS->getLayerId() == 0 ) 626 #else 639 627 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 628 #endif 640 629 { 641 630 #endif … … 701 690 if(pcSPS->getScalingListFlag()) 702 691 { 692 #if SCALINGLIST_INFERRING 693 if( pcSPS->getLayerId() > 0 ) 694 { 695 READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setInferScalingListFlag( uiCode ); 696 } 697 698 if( pcSPS->getInferScalingListFlag() ) 699 { 700 READ_UVLC( uiCode, "sps_scaling_list_ref_layer_id" ); pcSPS->setScalingListRefLayerId( uiCode ); 701 702 // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive 703 assert( pcSPS->getScalingListRefLayerId() <= 62 ); 704 705 pcSPS->setScalingListPresentFlag( false ); 706 } 707 else 708 { 709 #endif 703 710 READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); 704 711 if(pcSPS->getScalingListPresentFlag ()) 705 712 { 706 707 #if IL_SL_SIGNALLING_N0371708 pcSPS->getScalingList()->setLayerId( pcSPS->getLayerId() );709 710 if( pcSPS->getLayerId() > 0 )711 {712 READ_FLAG( uiCode, "sps_pred_scaling_list_flag" ); pcSPS->setPredScalingListFlag ( uiCode );713 pcSPS->getScalingList()->setPredScalingListFlag( pcSPS->getPredScalingListFlag() );714 715 if( pcSPS->getPredScalingListFlag() )716 {717 READ_UVLC( uiCode, "scaling_list_sps_ref_layer_id" ); pcSPS->setScalingListRefLayerId( uiCode );718 719 // The value of sps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive720 assert( /*pcSPS->getScalingListRefLayerId() >= 0 &&*/ pcSPS->getScalingListRefLayerId() <= 62 );721 722 // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0723 if( pcSPS->getVPS()->getAvcBaseLayerFlag() )724 {725 assert( pcSPS->getScalingListRefLayerId() > 0 );726 }727 728 // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and729 // sps_infer_scaling_list_flag in the SPS is equal to 1, sps_infer_scaling_list_flag shall be equal to 0 for the SPS that is active for the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id730 assert( pcSPS->getSPS( pcSPS->getScalingListRefLayerId() )->getPredScalingListFlag() == false );731 732 // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB,733 // the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB734 assert( pcSPS->getVPS()->getScalingListLayerDependency( pcSPS->getLayerId(), pcSPS->getScalingListRefLayerId() ) == true );735 736 pcSPS->getScalingList()->setScalingListRefLayerId( pcSPS->getScalingListRefLayerId() );737 parseScalingList( pcSPS->getScalingList() );738 }739 else740 {741 parseScalingList( pcSPS->getScalingList() );742 }743 }744 else745 {746 parseScalingList( pcSPS->getScalingList() );747 }748 #else749 713 parseScalingList( pcSPS->getScalingList() ); 750 #endif 751 752 } 714 } 715 #if SCALINGLIST_INFERRING 716 } 717 #endif 753 718 } 754 719 READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode ); … … 813 778 { 814 779 #if SPS_EXTENSION 780 781 #if O0142_CONDITIONAL_SPS_EXTENSION 782 UInt spsExtensionTypeFlag[8]; 783 for (UInt i = 0; i < 8; i++) 784 { 785 READ_FLAG( spsExtensionTypeFlag[i], "sps_extension_type_flag" ); 786 } 787 if (spsExtensionTypeFlag[1]) 788 { 789 parseSPSExtension( pcSPS ); 790 } 791 if (spsExtensionTypeFlag[7]) 792 { 793 #else 815 794 parseSPSExtension( pcSPS ); 816 795 READ_FLAG( uiCode, "sps_extension2_flag"); 817 796 if(uiCode) 818 797 { 798 #endif 799 819 800 #endif 820 801 while ( xMoreRbspData() ) … … 846 827 { 847 828 Window& scaledWindow = pcSPS->getScaledRefLayerWindow(i); 829 #if O0098_SCALED_REF_LAYER_ID 830 READ_CODE( 6, uiCode, "scaled_ref_layer_left_id" ); pcSPS->setScaledRefLayerId( i, uiCode ); 831 #endif 848 832 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 849 833 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); … … 1090 1074 vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers); 1091 1075 } 1076 #endif 1077 #if VPS_TSLAYERS 1078 READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag"); vps->setMaxTSLayersPresentFlag(uiCode ? true : false); 1079 if (vps->getMaxTSLayersPresentFlag()) 1080 { 1081 for(i = 0; i < vps->getMaxLayers() - 1; i++) 1082 { 1083 READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1[i]" ); vps->setMaxTSLayersMinus1(i, uiCode); 1084 } 1085 } 1086 else 1087 { 1088 for( i = 0; i < vps->getMaxLayers() - 1; i++) 1089 { 1090 vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); 1091 } 1092 } 1092 1093 #endif 1093 1094 #if JCTVC_M0203_INTERLAYER_PRED_IDC … … 1208 1209 else 1209 1210 { 1211 #if VPS_DPB_SIZE_TABLE 1212 vps->setOutputLayerSetIdx( i, i ); 1213 #endif 1210 1214 // i <= (vps->getNumLayerSets() - 1) 1211 1215 // Assign OutputLayerFlag depending on default_one_target_output_layer_flag … … 1234 1238 } 1235 1239 1240 #if O0153_ALT_OUTPUT_LAYER_FLAG 1241 if( vps->getMaxLayers() > 1 ) 1242 { 1243 READ_FLAG( uiCode, "alt_output_layer_flag"); 1244 vps->setAltOuputLayerFlag( uiCode ? true : false ); 1245 } 1246 #endif 1247 1236 1248 #if REPN_FORMAT_IN_VPS 1237 1249 READ_FLAG( uiCode, "rep_format_idx_present_flag"); … … 1240 1252 if( vps->getRepFormatIdxPresentFlag() ) 1241 1253 { 1254 #if O0096_REP_FORMAT_INDEX 1255 READ_CODE( 8, uiCode, "vps_num_rep_formats_minus1" ); 1256 #else 1242 1257 READ_CODE( 4, uiCode, "vps_num_rep_formats_minus1" ); 1258 #endif 1243 1259 vps->setVpsNumRepFormats( uiCode + 1 ); 1244 1260 } … … 1263 1279 if( vps->getVpsNumRepFormats() > 1 ) 1264 1280 { 1281 #if O0096_REP_FORMAT_INDEX 1282 READ_CODE( 8, uiCode, "vps_rep_format_idx[i]" ); 1283 #else 1265 1284 READ_CODE( 4, uiCode, "vps_rep_format_idx[i]" ); 1285 #endif 1266 1286 vps->setVpsRepFormatIdx( i, uiCode ); 1267 1287 } … … 1305 1325 #endif 1306 1326 1327 #if VPS_DPB_SIZE_TABLE 1328 vps->deriveNumberOfSubDpbs(); 1329 for(i = 1; i < vps->getNumOutputLayerSets(); i++) 1330 { 1331 READ_FLAG( uiCode, "sub_layer_flag_info_present_flag[i]"); vps->setSubLayerFlagInfoPresentFlag( i, uiCode ? true : false ); 1332 for(j = 0; j < vps->getMaxTLayers(); j++) 1333 { 1334 if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) ) 1335 { 1336 READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag[i]"); vps->setSubLayerDpbInfoPresentFlag( i, j, uiCode ? true : false); 1337 } 1338 else 1339 { 1340 if( j == 0 ) // Always signal for the first sub-layer 1341 { 1342 vps->setSubLayerDpbInfoPresentFlag( i, j, true ); 1343 } 1344 else // if (j != 0) && !vps->getSubLayerFlagInfoPresentFlag(i) 1345 { 1346 vps->setSubLayerDpbInfoPresentFlag( i, j, false ); 1347 } 1348 } 1349 if( vps->getSubLayerDpbInfoPresentFlag(i, j) ) // If sub-layer DPB information is present 1350 { 1351 for(Int k = 0; k < vps->getNumSubDpbs(i); k++) 1352 { 1353 READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1[i][k][j]" ); vps->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode ); 1354 } 1355 READ_UVLC( uiCode, "max_vps_num_reorder_pics[i][j]" ); vps->setMaxVpsNumReorderPics( i, j, uiCode); 1356 READ_UVLC( uiCode, "max_vps_latency_increase_plus1[i][j]" ); vps->setMaxVpsLatencyIncreasePlus1( i, j, uiCode); 1357 } 1358 } 1359 } 1360 #endif 1307 1361 #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS 1308 1362 READ_UVLC( uiCode, "direct_dep_type_len_minus2"); vps->setDirectDepTypeLen(uiCode+2); 1363 #if O0096_DEFAULT_DEPENDENCY_TYPE 1364 READ_FLAG(uiCode, "default_direct_dependency_type_flag"); 1365 vps->setDefaultDirectDependecyTypeFlag(uiCode == 1? true : false); 1366 if (vps->getDefaultDirectDependencyTypeFlag()) 1367 { 1368 READ_CODE( vps->getDirectDepTypeLen(), uiCode, "default_direct_dependency_type" ); 1369 vps->setDefaultDirectDependecyType(uiCode); 1370 } 1371 #endif 1309 1372 for(i = 1; i < vps->getMaxLayers(); i++) 1310 1373 { … … 1313 1376 if (vps->getDirectDependencyFlag(i, j)) 1314 1377 { 1315 READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); vps->setDirectDependencyType(i, j, uiCode); 1316 } 1317 } 1318 } 1319 1320 #endif 1321 1322 #if IL_SL_SIGNALLING_N0371 1378 #if O0096_DEFAULT_DEPENDENCY_TYPE 1379 if (vps->getDefaultDirectDependencyTypeFlag()) 1380 { 1381 vps->setDirectDependencyType(i, j, vps->getDefaultDirectDependencyType()); 1382 } 1383 else 1384 { 1385 READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); 1386 vps->setDirectDependencyType(i, j, uiCode); 1387 } 1388 #else 1389 READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); 1390 vps->setDirectDependencyType(i, j, uiCode); 1391 #endif 1392 } 1393 } 1394 } 1395 #endif 1396 #if O0092_0094_DEPENDENCY_CONSTRAINT 1323 1397 for(i = 1; i < vps->getMaxLayers(); i++) 1324 { 1325 for(j = 0; j < i; j++) 1326 { 1327 vps->setScalingListLayerDependency( i, j, vps->checkLayerDependency( i,j ) ); 1328 } 1329 } 1398 { 1399 vps->setNumRefLayers(vps->getLayerIdInNuh(i)); // identify the number of direct and indirect reference layers of current layer and set recursiveRefLayersFlags 1400 } 1401 if(vps->getMaxLayers() > MAX_REF_LAYERS) 1402 { 1403 for(i = 1;i < vps->getMaxLayers(); i++) 1404 { 1405 assert( vps->getNumRefLayers(vps->getLayerIdInNuh(i)) <= MAX_REF_LAYERS); 1406 } 1407 } 1330 1408 #endif 1331 1409 … … 1333 1411 READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); 1334 1412 #endif 1413 #if HIGHER_LAYER_IRAP_SKIP_FLAG 1414 READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false); 1415 #endif 1335 1416 1336 1417 READ_FLAG( uiCode, "vps_vui_present_flag" ); … … 1351 1432 { 1352 1433 UInt uiCode; 1434 #if REPN_FORMAT_CONTROL_FLAG 1435 READ_FLAG ( uiCode, "chroma_and_bit_depth_vps_present_flag"); repFormat->setChromaAndBitDepthVpsPresentFlag(uiCode ? true : false); 1436 READ_CODE ( 16, uiCode, "pic_width_in_luma_samples" ); repFormat->setPicWidthVpsInLumaSamples ( uiCode ); 1437 READ_CODE ( 16, uiCode, "pic_height_in_luma_samples" ); repFormat->setPicHeightVpsInLumaSamples( uiCode ); 1438 1439 if( repFormat->getChromaAndBitDepthVpsPresentFlag() ) 1440 { 1441 #if AUXILIARY_PICTURES 1442 READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) ); 1443 #else 1444 READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( uiCode ); 1445 #endif 1446 1447 if( repFormat->getChromaFormatVpsIdc() == 3 ) 1448 { 1449 READ_FLAG( uiCode, "separate_colour_plane_flag"); repFormat->setSeparateColourPlaneVpsFlag(uiCode ? true : false); 1450 } 1451 1452 1453 READ_CODE( 4, uiCode, "bit_depth_luma_minus8" ); repFormat->setBitDepthVpsLuma ( uiCode + 8 ); 1454 READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); 1455 } 1456 #else 1353 1457 #if AUXILIARY_PICTURES 1354 1458 READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) ); … … 1367 1471 READ_CODE( 4, uiCode, "bit_depth_luma_minus8" ); repFormat->setBitDepthVpsLuma ( uiCode + 8 ); 1368 1472 READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); 1369 1473 #endif 1370 1474 } 1371 1475 #endif … … 1375 1479 UInt i,j; 1376 1480 UInt uiCode; 1481 #if O0223_PICTURE_TYPES_ALIGN_FLAG 1482 READ_FLAG(uiCode, "cross_layer_pic_type_aligned_flag" ); 1483 vps->setCrossLayerPictureTypeAlignFlag(uiCode); 1484 if (!uiCode) 1485 { 1486 #endif 1377 1487 #if IRAP_ALIGN_FLAG_IN_VPS_VUI 1378 READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" ); 1379 vps->setCrossLayerIrapAlignFlag(uiCode); 1488 READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" ); 1489 vps->setCrossLayerIrapAlignFlag(uiCode); 1490 #endif 1491 #if O0223_PICTURE_TYPES_ALIGN_FLAG 1492 } 1493 else 1494 { 1495 vps->setCrossLayerIrapAlignFlag(true); 1496 } 1380 1497 #endif 1381 1498 #if VPS_VUI_BITRATE_PICRATE … … 1429 1546 } 1430 1547 #endif 1548 #if VPS_VUI_TILES_NOT_IN_USE__FLAG 1549 UInt layerIdx; 1550 READ_FLAG( uiCode, "tiles_not_in_use_flag" ); vps->setTilesNotInUseFlag(uiCode == 1); 1551 if (!uiCode) 1552 { 1553 for(i = 0; i < vps->getMaxLayers(); i++) 1554 { 1555 READ_FLAG( uiCode, "tiles_in_use_flag[ i ]" ); vps->setTilesInUseFlag(i, (uiCode == 1)); 1556 if (uiCode) 1557 { 1558 READ_FLAG( uiCode, "loop_filter_not_across_tiles_flag[ i ]" ); vps->setLoopFilterNotAcrossTilesFlag(i, (uiCode == 1)); 1559 } 1560 else 1561 { 1562 vps->setLoopFilterNotAcrossTilesFlag(i, false); 1563 } 1564 } 1565 #endif 1431 1566 #if TILE_BOUNDARY_ALIGNED_FLAG 1432 for(i = 1; i < vps->getMaxLayers(); i++) 1433 { 1434 for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) 1435 { 1436 READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); 1567 for(i = 1; i < vps->getMaxLayers(); i++) 1568 { 1569 for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) 1570 { 1571 #if VPS_VUI_TILES_NOT_IN_USE__FLAG 1572 layerIdx = vps->getLayerIdInVps(vps->getRefLayerId(vps->getLayerIdInNuh(i), j)); 1573 if (vps->getTilesInUseFlag(i) && vps->getTilesInUseFlag(layerIdx)) { 1574 READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); 1575 } 1576 #else 1577 READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); 1578 #endif 1579 } 1580 } 1581 #endif 1582 #if VPS_VUI_TILES_NOT_IN_USE__FLAG 1583 } 1584 #endif 1585 #if VPS_VUI_WPP_NOT_IN_USE__FLAG 1586 READ_FLAG( uiCode, "wpp_not_in_use_flag" ); vps->setWppNotInUseFlag(uiCode == 1); 1587 if (!uiCode) 1588 { 1589 for(i = 0; i < vps->getMaxLayers(); i++) 1590 { 1591 READ_FLAG( uiCode, "wpp_in_use_flag[ i ]" ); vps->setWppInUseFlag(i, (uiCode == 1)); 1437 1592 } 1438 1593 } … … 1458 1613 } 1459 1614 } 1615 #endif 1616 #if VPS_VUI_VIDEO_SIGNAL 1617 READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); 1618 if (vps->getVideoSigPresentVpsFlag()) 1619 { 1620 READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1); 1621 } 1622 else 1623 { 1624 vps->setNumVideoSignalInfo(vps->getMaxLayers()); 1625 } 1626 1627 1628 for(i = 0; i < vps->getNumVideoSignalInfo(); i++) 1629 { 1630 READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode); 1631 READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode); 1632 READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode); 1633 READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode); 1634 READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); 1635 } 1636 if(!vps->getVideoSigPresentVpsFlag()) 1637 { 1638 for (i=0; i < vps->getMaxLayers(); i++) 1639 { 1640 vps->setVideoSignalInfoIdx(i,i); 1641 } 1642 } 1643 else { 1644 vps->setVideoSignalInfoIdx(0,0); 1645 if (vps->getNumVideoSignalInfo() > 1 ) 1646 { 1647 for (i=1; i < vps->getMaxLayers(); i++) 1648 READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); 1649 } 1650 else { 1651 for (i=1; i < vps->getMaxLayers(); i++) 1652 { 1653 vps->setVideoSignalInfoIdx(i,0); 1654 } 1655 } 1656 } 1460 1657 #endif 1461 1658 } … … 1548 1745 iBits++; 1549 1746 } 1747 #if O0149_CROSS_LAYER_BLA_FLAG 1748 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 1749 { 1750 READ_FLAG(uiCode, "cross_layer_bla_flag"); rpcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); 1751 iBits++; 1752 } 1753 #endif 1550 1754 for (; iBits < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) 1551 1755 { … … 1734 1938 Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB 1735 1939 - iPOClsb + pocLsbLt; 1736 1737 1940 rps->setPOC (j, pocLTCurr); 1738 1941 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); … … 1837 2040 else 1838 2041 { 2042 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 2043 if( (rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) > rpcSlice->getTLayer()) && 2044 (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >= rpcSlice->getTLayer()) ) 2045 { 2046 #endif 1839 2047 rpcSlice->setActiveNumILRRefIdx(1); 1840 2048 rpcSlice->setInterLayerPredLayerIdc(0,0); 2049 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 2050 } 2051 #endif 1841 2052 } 1842 2053 } … … 1844 2055 #if ILP_SSH_SIG 1845 2056 #if ILP_SSH_SIG_FIX 1846 else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true )2057 else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true && (rpcSlice->getLayerId() > 0 )) 1847 2058 #else 1848 2059 else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == false ) … … 1850 2061 { 1851 2062 rpcSlice->setInterLayerPredEnabledFlag(true); 2063 2064 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 2065 Int numRefLayerPics = 0; 2066 Int i = 0; 2067 Int refLayerPicIdc [MAX_VPS_LAYER_ID_PLUS1]; 2068 for(i = 0, numRefLayerPics = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) 2069 { 2070 if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && 2071 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 2072 { 2073 refLayerPicIdc[ numRefLayerPics++ ] = i; 2074 } 2075 } 2076 rpcSlice->setActiveNumILRRefIdx(numRefLayerPics); 2077 for( i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 2078 { 2079 rpcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i],i); 2080 } 2081 #else 1852 2082 rpcSlice->setActiveNumILRRefIdx(rpcSlice->getNumILRRefIdx()); 1853 2083 for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) … … 1855 2085 rpcSlice->setInterLayerPredLayerIdc(i,i); 1856 2086 } 2087 #endif 1857 2088 } 1858 2089 #endif … … 1879 2110 ChromaFormat format; 1880 2111 #if REPN_FORMAT_IN_VPS 2112 #if O0096_REP_FORMAT_INDEX 2113 if( sps->getLayerId() == 0 ) 2114 { 2115 format = sps->getChromaFormatIdc(); 2116 } 2117 else 2118 { 2119 format = rpcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); 2120 } 2121 #else 1881 2122 if( ( sps->getLayerId() == 0 ) || sps->getUpdateRepFormatFlag() ) 1882 2123 { … … 1887 2128 format = rpcSlice->getVPS()->getVpsRepFormat( rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); 1888 2129 } 2130 #endif 1889 2131 #else 1890 2132 format = sps->getChromaFormatIdc(); … … 2039 2281 #if M0457_COL_PICTURE_SIGNALING 2040 2282 #if REMOVE_COL_PICTURE_SIGNALING 2041 rpcSlice->setMFMEnabledFlag( rpcSlice->getNumMotionPredRefLayers() > 0? true : false );2283 rpcSlice->setMFMEnabledFlag( ( rpcSlice->getNumMotionPredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() ) ? true : false ); 2042 2284 #else 2043 2285 rpcSlice->setMFMEnabledFlag( false ); … … 2633 2875 UInt code, sizeId, listId; 2634 2876 Bool scalingListPredModeFlag; 2635 2636 2877 //for each size 2637 2878 for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) … … 2639 2880 for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) 2640 2881 { 2641 #if IL_SL_SIGNALLING_N03712642 if ( scalingList->getLayerId() > 0 && scalingList->getPredScalingListFlag() )2643 {2644 READ_FLAG( code, "scaling_list_pred_mode_flag");2645 scalingListPredModeFlag = (code) ? true : false;2646 if(!scalingListPredModeFlag) //Copy Mode2647 {2648 READ_UVLC( code, "scaling_list_pred_matrix_id_delta");2649 scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code)));2650 if( sizeId > SCALING_LIST_8x8 )2651 {2652 scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId))));2653 }2654 scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId));2655 2656 }2657 else //DPCM Mode2658 {2659 xDecodeScalingList(scalingList, sizeId, listId);2660 }2661 }2662 else2663 {2664 READ_FLAG( code, "scaling_list_pred_mode_flag");2665 scalingListPredModeFlag = (code) ? true : false;2666 if(!scalingListPredModeFlag) //Copy Mode2667 {2668 READ_UVLC( code, "scaling_list_pred_matrix_id_delta");2669 scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code)));2670 if( sizeId > SCALING_LIST_8x8 )2671 {2672 scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId))));2673 }2674 scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId));2675 2676 }2677 else //DPCM Mode2678 {2679 xDecodeScalingList(scalingList, sizeId, listId);2680 }2681 }2682 #else2683 2882 READ_FLAG( code, "scaling_list_pred_mode_flag"); 2684 2883 scalingListPredModeFlag = (code) ? true : false; … … 2698 2897 xDecodeScalingList(scalingList, sizeId, listId); 2699 2898 } 2700 #endif2701 2899 } 2702 2900 } … … 2720 2918 if( sizeId > SCALING_LIST_8x8 ) 2721 2919 { 2722 #if IL_SL_SIGNALLING_N03712723 if( scalingList->getLayerId() > 0 && scalingList->getPredScalingListFlag() )2724 {2725 ref_scalingListDC[scalingList->getLayerId()][sizeId][listId] = scalingList->getScalingListDC(sizeId,listId);2726 scalingList->setScalingListDC(sizeId,listId,ref_scalingListDC[scalingList->getScalingListRefLayerId()][sizeId][listId]);2727 }2728 else2729 {2730 READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8");2731 scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8);2732 nextCoef = scalingList->getScalingListDC(sizeId,listId);2733 ref_scalingListDC[scalingList->getLayerId()][sizeId][listId] = scalingList->getScalingListDC(sizeId,listId);2734 }2735 #else2736 2920 READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); 2737 2921 scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); 2738 2922 nextCoef = scalingList->getScalingListDC(sizeId,listId); 2739 #endif2740 2923 } 2741 2924 2742 2925 for(i = 0; i < coefNum; i++) 2743 2926 { 2744 #if IL_SL_SIGNALLING_N03712745 if( scalingList->getLayerId() > 0 && scalingList->getPredScalingListFlag() )2746 {2747 ref_scalingListCoef[scalingList->getLayerId()][sizeId][listId][i] = dst[scan[i]];2748 dst[scan[i]] = ref_scalingListCoef[scalingList->getScalingListRefLayerId()][sizeId][listId][i];2749 }2750 else2751 {2752 READ_SVLC( data, "scaling_list_delta_coef");2753 nextCoef = (nextCoef + data + 256 ) % 256;2754 dst[scan[i]] = nextCoef;2755 ref_scalingListCoef[scalingList->getLayerId()][sizeId][listId][i] = dst[scan[i]];2756 }2757 #else2758 2927 READ_SVLC( data, "scaling_list_delta_coef"); 2759 2928 nextCoef = (nextCoef + data + 256 ) % 256; 2760 2929 dst[scan[i]] = nextCoef; 2761 #endif2762 2930 } 2763 2931 } … … 2791 2959 return (cnt>0); 2792 2960 } 2961 2793 2962 //! \} 2794 2963 -
trunk/source/Lib/TLibDecoder/TDecCu.cpp
r494 r540 317 317 } 318 318 319 #if HIGHER_LAYER_IRAP_SKIP_FLAG 320 if (pcCU->getSlice()->getVPS()->getHigherLayerIrapSkipFlag() && pcCU->getSlice()->getVPS()->getSingleLayerForNonIrapFlag() && pcCU->getLayerId() > 0) 321 { 322 Bool lowerLayerExist = false; 323 for(int i=0;i<pcCU->getLayerId();i++) 324 { 325 if(pcCU->getSlice()->getBaseColPic(pcCU->getSlice()->getInterLayerPredLayerIdc(i))) 326 { 327 lowerLayerExist = true; 328 } 329 } 330 if(lowerLayerExist) 331 { 332 assert(pcCU->isSkipped(uiAbsPartIdx)); 333 } 334 } 335 #endif 336 319 337 if( pcCU->isSkipped(uiAbsPartIdx) ) 320 338 { … … 945 963 946 964 } 965 947 966 //! \} -
trunk/source/Lib/TLibDecoder/TDecEntropy.h
r494 r540 106 106 virtual Void parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) = 0; 107 107 virtual Void parseTransformSkipFlags ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, UInt uiDepth, TextType eTType) = 0; 108 109 108 virtual Void updateContextTables( SliceType eSliceType, Int iQp ) = 0; 110 109 … … 166 165 Void updateContextTables ( SliceType eSliceType, Int iQp ) { m_pcEntropyDecoderIf->updateContextTables( eSliceType, iQp ); } 167 166 167 168 168 private: 169 169 Void xDecodeTransform ( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP ); -
trunk/source/Lib/TLibDecoder/TDecGop.cpp
r442 r540 128 128 //-- For time output for each slice 129 129 long iBeforeTime = clock(); 130 130 #if !HM_CLEANUP_SAO 131 131 UInt uiStartCUAddr = pcSlice->getSliceSegmentCurStartCUAddr(); 132 132 … … 136 136 m_sliceStartCUAddress.push_back(uiSliceStartCuAddr); 137 137 } 138 138 #endif 139 139 m_pcSbacDecoder->init( (TDecBinIf*)m_pcBinCABAC ); 140 140 m_pcEntropyDecoder->setEntropyDecoder (m_pcSbacDecoder); … … 163 163 m_pcEntropyDecoder->setBitstream ( ppcSubstreams[0] ); 164 164 m_pcEntropyDecoder->resetEntropy (pcSlice); 165 165 #if !HM_CLEANUP_SAO 166 166 if(uiSliceStartCuAddr == uiStartCUAddr) 167 167 { 168 168 m_LFCrossSliceBoundaryFlag.push_back( pcSlice->getLFCrossSliceBoundaryFlag()); 169 169 } 170 #endif 170 171 m_pcSbacDecoders[0].load(m_pcSbacDecoder); 171 172 m_pcSliceDecoder->decompressSlice( ppcSubstreams, rpcPic, m_pcSbacDecoder, m_pcSbacDecoders); … … 195 196 m_pcLoopFilter->setCfg(bLFCrossTileBoundary); 196 197 m_pcLoopFilter->loopFilterPic( rpcPic ); 197 198 #if !HM_CLEANUP_SAO 198 199 if(pcSlice->getSPS()->getUseSAO()) 199 200 { … … 201 202 rpcPic->createNonDBFilterInfo(m_sliceStartCUAddress, 0, &m_LFCrossSliceBoundaryFlag, rpcPic->getPicSym()->getNumTiles(), bLFCrossTileBoundary); 202 203 } 203 204 #endif 204 205 if( pcSlice->getSPS()->getUseSAO() ) 205 206 { 207 #if HM_CLEANUP_SAO 208 m_pcSAO->reconstructBlkSAOParams(rpcPic, rpcPic->getPicSym()->getSAOBlkParam()); 209 m_pcSAO->SAOProcess(rpcPic); 210 m_pcSAO->PCMLFDisableProcess(rpcPic); 211 #else 206 212 { 207 213 SAOParam *saoParam = rpcPic->getPicSym()->getSaoParam(); … … 214 220 m_pcSAO->destroyPicSaoInfo(); 215 221 } 216 } 217 222 #endif 223 } 224 #if !HM_CLEANUP_SAO 218 225 if(pcSlice->getSPS()->getUseSAO()) 219 226 { 220 227 rpcPic->destroyNonDBFilterInfo(); 221 228 } 222 229 #endif 223 230 rpcPic->compressMotion(); 224 231 Char c = (pcSlice->isIntra() ? 'I' : pcSlice->isInterP() ? 'P' : 'B'); … … 283 290 rpcPic->setOutputMark(true); 284 291 rpcPic->setReconMark(true); 292 #if !HM_CLEANUP_SAO 285 293 m_sliceStartCUAddress.clear(); 286 294 m_LFCrossSliceBoundaryFlag.clear(); 295 #endif 287 296 } 288 297 -
trunk/source/Lib/TLibDecoder/TDecGop.h
r313 r540 83 83 Int m_decodedPictureHashSEIEnabled; ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message 84 84 85 #if !HM_CLEANUP_SAO 85 86 //! list that contains the CU address of each slice plus the end address 86 87 std::vector<Int> m_sliceStartCUAddress; 87 88 std::vector<Bool> m_LFCrossSliceBoundaryFlag; 88 89 #endif 89 90 #if SVC_EXTENSION 90 91 UInt m_layerId; -
trunk/source/Lib/TLibDecoder/TDecSbac.cpp
r494 r540 368 368 #if AUXILIARY_PICTURES 369 369 if (format == CHROMA_400) 370 { 370 371 uiSample = uiGrayVal; 372 } 371 373 else 372 374 #endif … … 389 391 #if AUXILIARY_PICTURES 390 392 if (format == CHROMA_400) 393 { 391 394 uiSample = uiGrayVal; 395 } 392 396 else 393 397 #endif … … 1378 1382 if (uiCode == 0) 1379 1383 { 1384 #if HM_CLEANUP_SAO 1385 ruiVal = 1; 1386 #else 1380 1387 ruiVal = 5; 1388 #endif 1381 1389 } 1382 1390 else 1383 1391 { 1392 #if HM_CLEANUP_SAO 1393 ruiVal = 2; 1394 #else 1384 1395 ruiVal = 1; 1385 } 1386 } 1387 } 1396 #endif 1397 } 1398 } 1399 } 1400 1401 #if HM_CLEANUP_SAO 1402 1403 Void TDecSbac::parseSaoSign(UInt& val) 1404 { 1405 m_pcTDecBinIf->decodeBinEP ( val ); 1406 } 1407 1408 Void TDecSbac::parseSAOBlkParam (SAOBlkParam& saoBlkParam 1409 , Bool* sliceEnabled 1410 , Bool leftMergeAvail 1411 , Bool aboveMergeAvail 1412 ) 1413 { 1414 UInt uiSymbol; 1415 1416 Bool isLeftMerge = false; 1417 Bool isAboveMerge= false; 1418 1419 if(leftMergeAvail) 1420 { 1421 parseSaoMerge(uiSymbol); //sao_merge_left_flag 1422 isLeftMerge = (uiSymbol?true:false); 1423 } 1424 1425 if( aboveMergeAvail && !isLeftMerge) 1426 { 1427 parseSaoMerge(uiSymbol); //sao_merge_up_flag 1428 isAboveMerge = (uiSymbol?true:false); 1429 } 1430 1431 if(isLeftMerge || isAboveMerge) //merge mode 1432 { 1433 saoBlkParam[SAO_Y].modeIdc = saoBlkParam[SAO_Cb].modeIdc = saoBlkParam[SAO_Cr].modeIdc = SAO_MODE_MERGE; 1434 saoBlkParam[SAO_Y].typeIdc = saoBlkParam[SAO_Cb].typeIdc = saoBlkParam[SAO_Cr].typeIdc = (isLeftMerge)?SAO_MERGE_LEFT:SAO_MERGE_ABOVE; 1435 } 1436 else //new or off mode 1437 { 1438 for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++) 1439 { 1440 SAOOffset& ctbParam = saoBlkParam[compIdx]; 1441 1442 if(!sliceEnabled[compIdx]) 1443 { 1444 //off 1445 ctbParam.modeIdc = SAO_MODE_OFF; 1446 continue; 1447 } 1448 1449 //type 1450 if(compIdx == SAO_Y || compIdx == SAO_Cb) 1451 { 1452 parseSaoTypeIdx(uiSymbol); //sao_type_idx_luma or sao_type_idx_chroma 1453 1454 assert(uiSymbol ==0 || uiSymbol ==1 || uiSymbol ==2); 1455 1456 if(uiSymbol ==0) //OFF 1457 { 1458 ctbParam.modeIdc = SAO_MODE_OFF; 1459 } 1460 else if(uiSymbol == 1) //BO 1461 { 1462 ctbParam.modeIdc = SAO_MODE_NEW; 1463 ctbParam.typeIdc = SAO_TYPE_START_BO; 1464 } 1465 else //2, EO 1466 { 1467 ctbParam.modeIdc = SAO_MODE_NEW; 1468 ctbParam.typeIdc = SAO_TYPE_START_EO; 1469 } 1470 1471 } 1472 else //Cr, follow Cb SAO type 1473 { 1474 ctbParam.modeIdc = saoBlkParam[SAO_Cb].modeIdc; 1475 ctbParam.typeIdc = saoBlkParam[SAO_Cb].typeIdc; 1476 } 1477 1478 if(ctbParam.modeIdc == SAO_MODE_NEW) 1479 { 1480 Int offset[4]; 1481 for(Int i=0; i< 4; i++) 1482 { 1483 parseSaoMaxUvlc(uiSymbol, g_saoMaxOffsetQVal[compIdx] ); //sao_offset_abs 1484 offset[i] = (Int)uiSymbol; 1485 } 1486 1487 if(ctbParam.typeIdc == SAO_TYPE_START_BO) 1488 { 1489 for(Int i=0; i< 4; i++) 1490 { 1491 if(offset[i] != 0) 1492 { 1493 parseSaoSign(uiSymbol); //sao_offset_sign 1494 if(uiSymbol) 1495 { 1496 offset[i] = -offset[i]; 1497 } 1498 } 1499 } 1500 parseSaoUflc(NUM_SAO_BO_CLASSES_LOG2, uiSymbol ); //sao_band_position 1501 ctbParam.typeAuxInfo = uiSymbol; 1502 1503 for(Int i=0; i<4; i++) 1504 { 1505 ctbParam.offset[(ctbParam.typeAuxInfo+i)%MAX_NUM_SAO_CLASSES] = offset[i]; 1506 } 1507 1508 } 1509 else //EO 1510 { 1511 ctbParam.typeAuxInfo = 0; 1512 1513 if(compIdx == SAO_Y || compIdx == SAO_Cb) 1514 { 1515 parseSaoUflc(NUM_SAO_EO_TYPES_LOG2, uiSymbol ); //sao_eo_class_luma or sao_eo_class_chroma 1516 ctbParam.typeIdc += uiSymbol; 1517 } 1518 else 1519 { 1520 ctbParam.typeIdc = saoBlkParam[SAO_Cb].typeIdc; 1521 } 1522 ctbParam.offset[SAO_CLASS_EO_FULL_VALLEY] = offset[0]; 1523 ctbParam.offset[SAO_CLASS_EO_HALF_VALLEY] = offset[1]; 1524 ctbParam.offset[SAO_CLASS_EO_PLAIN ] = 0; 1525 ctbParam.offset[SAO_CLASS_EO_HALF_PEAK ] = -offset[2]; 1526 ctbParam.offset[SAO_CLASS_EO_FULL_PEAK ] = -offset[3]; 1527 } 1528 } 1529 } 1530 } 1531 } 1532 1533 #else 1388 1534 1389 1535 inline Void copySaoOneLcuParam(SaoLcuParam* psDst, SaoLcuParam* psSrc) … … 1559 1705 } 1560 1706 1707 #endif 1708 1561 1709 /** 1562 1710 - Initialize our contexts from the nominated source. -
trunk/source/Lib/TLibDecoder/TDecSbac.h
r494 r540 90 90 Void parseSaoTypeIdx ( UInt& ruiVal ); 91 91 Void parseSaoUflc ( UInt uiLength, UInt& ruiVal ); 92 #if HM_CLEANUP_SAO 93 Void parseSAOBlkParam (SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail); 94 Void parseSaoSign(UInt& val); 95 #else 92 96 Void parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp); 93 97 Void parseSaoOffset (SaoLcuParam* psSaoLcuParam, UInt compIdx); 98 #endif 94 99 private: 95 100 Void xReadUnarySymbol ( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset ); -
trunk/source/Lib/TLibDecoder/TDecSlice.cpp
r345 r540 197 197 UInt uiTileLCUX; 198 198 Int iNumSubstreamsPerTile = 1; // if independent. 199 200 199 Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag(); 201 200 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr(); … … 323 322 g_bJustDoIt = g_bEncDecTraceEnable; 324 323 #endif 324 325 #if HM_CLEANUP_SAO 326 if ( pcSlice->getSPS()->getUseSAO() ) 327 { 328 SAOBlkParam& saoblkParam = (rpcPic->getPicSym()->getSAOBlkParam())[iCUAddr]; 329 if (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) 330 { 331 Bool sliceEnabled[NUM_SAO_COMPONENTS]; 332 sliceEnabled[SAO_Y] = pcSlice->getSaoEnabledFlag(); 333 sliceEnabled[SAO_Cb]= sliceEnabled[SAO_Cr]= pcSlice->getSaoEnabledFlagChroma(); 334 335 Bool leftMergeAvail = false; 336 Bool aboveMergeAvail= false; 337 338 //merge left condition 339 Int rx = (iCUAddr % uiWidthInLCUs); 340 if(rx > 0) 341 { 342 leftMergeAvail = rpcPic->getSAOMergeAvailability(iCUAddr, iCUAddr-1); 343 } 344 //merge up condition 345 Int ry = (iCUAddr / uiWidthInLCUs); 346 if(ry > 0) 347 { 348 aboveMergeAvail = rpcPic->getSAOMergeAvailability(iCUAddr, iCUAddr-uiWidthInLCUs); 349 } 350 351 pcSbacDecoder->parseSAOBlkParam( saoblkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail); 352 } 353 else 354 { 355 saoblkParam[SAO_Y ].modeIdc = SAO_MODE_OFF; 356 saoblkParam[SAO_Cb].modeIdc = SAO_MODE_OFF; 357 saoblkParam[SAO_Cr].modeIdc = SAO_MODE_OFF; 358 } 359 } 360 #else 325 361 if ( pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) ) 326 362 { … … 374 410 } 375 411 } 412 #endif 413 376 414 m_pcCuDecoder->decodeCU ( pcCU, uiIsLast ); 377 415 m_pcCuDecoder->decompressCU ( pcCU ); -
trunk/source/Lib/TLibDecoder/TDecTop.cpp
r494 r540 79 79 m_prevSliceSkipped = false; 80 80 m_skippedPOC = 0; 81 #if NO_CLRAS_OUTPUT_FLAG 82 m_noClrasOutputFlag = false; 83 m_layerInitializedFlag = false; 84 m_firstPicInLayerDecodedFlag = false; 85 m_noOutputOfPriorPicsFlags = false; 86 m_bRefreshPending = false; 87 #endif 81 88 } 82 89 … … 170 177 for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) 171 178 { 179 #if USE_DPB_SIZE_TABLE 180 if( getCommonDecoderParams()->getOutputLayerSetIdx() == 0 ) 181 { 182 assert( this->getLayerId() == 0 ); 183 numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer); 184 } 185 else 186 { 187 TComVPS *vps = slice->getVPS(); 188 // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures. 189 numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getOutputLayerSetIdx() , temporalLayer); 190 } 191 #else 172 192 numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer); 193 #endif 173 194 } 174 195 … … 260 281 for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) 261 282 { 283 #if USE_DPB_SIZE_TABLE 284 if( getCommonDecoderParams()->getOutputLayerSetIdx() == 0 ) 285 { 286 assert( this->getLayerId() == 0 ); 287 numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer); 288 } 289 else 290 { 291 TComVPS *vps = pcSlice->getVPS(); 292 // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures. 293 numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getOutputLayerSetIdx() , temporalLayer); 294 } 295 #else 262 296 numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer); 263 } 264 297 #endif 298 } 299 300 #if USE_DPB_SIZE_TABLE 301 if( getCommonDecoderParams()->getOutputLayerSetIdx() == 0 ) 302 { 303 assert( this->getLayerId() == 0 ); 304 m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer()); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded 305 } 306 else 307 { 308 m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1( getCommonDecoderParams()->getOutputLayerSetIdx(), pcSlice->getLayerId(), pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded 309 } 310 #else 265 311 m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer()); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded 312 #endif 266 313 267 314 #if SVC_EXTENSION … … 278 325 for(UInt i = 0; i < pcSlice->getVPS()->getNumDirectRefLayers( m_layerId ); i++ ) 279 326 { 327 #if O0098_SCALED_REF_LAYER_ID 328 const Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, i)); 329 #else 280 330 const Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(i); 331 #endif 281 332 Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); 282 333 … … 344 395 #endif 345 396 #endif 346 397 #if !HM_CLEANUP_SAO 347 398 rpcPic->getPicSym()->allocSaoParam(&m_cSAO); 399 #endif 348 400 m_cListPic.pushBack( rpcPic ); 349 401 … … 425 477 #endif 426 478 #endif 479 #if !HM_CLEANUP_SAO 427 480 rpcPic->getPicSym()->allocSaoParam(&m_cSAO); 481 #endif 428 482 } 429 483 … … 531 585 printf("\ninserting lost poc : %d\n",iLostPoc); 532 586 TComSlice cFillSlice; 533 #if SVC_EXTENSION534 cFillSlice.setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() );535 cFillSlice.setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() );536 cFillSlice.setVPS( m_parameterSetManagerDecoder[m_layerId].getFirstVPS() );537 cFillSlice.initSlice( m_layerId );538 #else539 587 cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); 540 588 cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); 589 #if SVC_EXTENSION 590 cFillSlice.setVPS( m_parameterSetManagerDecoder.getFirstVPS() ); 591 cFillSlice.initSlice( m_layerId ); 592 #else 541 593 cFillSlice.initSlice(); 542 594 #endif 543 595 TComPic *cFillPic; 544 596 xGetNewPicBuffer(&cFillSlice,cFillPic); 545 #if SVC_EXTENSION546 cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() );547 cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() );548 cFillPic->getSlice(0)->setVPS( m_parameterSetManagerDecoder[m_layerId].getFirstVPS() );549 cFillPic->getSlice(0)->initSlice( m_layerId );550 #else551 597 cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); 552 598 cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); 599 #if SVC_EXTENSION 600 cFillPic->getSlice(0)->setVPS( m_parameterSetManagerDecoder.getFirstVPS() ); 601 cFillPic->getSlice(0)->initSlice( m_layerId ); 602 #else 553 603 cFillPic->getSlice(0)->initSlice(); 554 604 #endif … … 593 643 Void TDecTop::xActivateParameterSets() 594 644 { 595 #if SVC_EXTENSION596 m_parameterSetManagerDecoder[m_layerId].applyPrefetchedPS();597 598 TComPPS *pps = m_parameterSetManagerDecoder[m_layerId].getPPS(m_apcSlicePilot->getPPSId());599 assert (pps != 0);600 601 TComSPS *sps = m_parameterSetManagerDecoder[m_layerId].getSPS(pps->getSPSId());602 assert (sps != 0);603 604 if( false == m_parameterSetManagerDecoder[m_layerId].activatePPS(m_apcSlicePilot->getPPSId(), m_apcSlicePilot->isIRAP()) )605 #else606 645 m_parameterSetManagerDecoder.applyPrefetchedPS(); 607 646 … … 613 652 614 653 if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP())) 615 #endif616 654 { 617 655 printf ("Parameter set activation failed!"); 618 656 assert (0); 619 657 } 658 659 #if SCALINGLIST_INFERRING 660 // scaling list settings and checks 661 TComVPS *activeVPS = m_parameterSetManagerDecoder.getActiveVPS(); 662 TComSPS *activeSPS = m_parameterSetManagerDecoder.getActiveSPS(); 663 TComPPS *activePPS = m_parameterSetManagerDecoder.getActivePPS(); 664 665 if( activeSPS->getInferScalingListFlag() ) 666 { 667 UInt refLayerId = activeSPS->getScalingListRefLayerId(); 668 TComSPS *refSps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActiveSPS(); assert( refSps != NULL ); 669 670 // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0 671 if( activeVPS->getAvcBaseLayerFlag() ) 672 { 673 assert( refLayerId > 0 ); 674 } 675 676 // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and 677 // sps_infer_scaling_list_flag in the SPS is equal to 1, sps_infer_scaling_list_flag shall be equal to 0 for the SPS that is active for the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id 678 assert( refSps->getInferScalingListFlag() == false ); 679 680 // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB, 681 // the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB 682 assert( activeVPS->getRecursiveRefLayerFlag( activeSPS->getLayerId(), refLayerId ) == true ); 683 684 if( activeSPS->getScalingList() != refSps->getScalingList() ) 685 { 686 // delete created instance of scaling list since it will be inferred 687 delete activeSPS->getScalingList(); 688 689 // infer scaling list 690 activeSPS->setScalingList( refSps->getScalingList() ); 691 } 692 } 693 694 if( activePPS->getInferScalingListFlag() ) 695 { 696 UInt refLayerId = activePPS->getScalingListRefLayerId(); 697 TComPPS *refPps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActivePPS(); assert( refPps != NULL ); 698 699 // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0 700 if( activeVPS->getAvcBaseLayerFlag() ) 701 { 702 assert( refLayerId > 0 ); 703 } 704 705 // It is a requirement of bitstream conformance that, when an PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and 706 // pps_infer_scaling_list_flag in the PPS is equal to 1, pps_infer_scaling_list_flag shall be equal to 0 for the PPS that is active for the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id 707 assert( refPps->getInferScalingListFlag() == false ); 708 709 // It is a requirement of bitstream conformance that, when an PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB, 710 // the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB 711 assert( activeVPS->getRecursiveRefLayerFlag( activePPS->getLayerId(), refLayerId ) == true ); 712 713 if( activePPS->getScalingList() != refPps->getScalingList() ) 714 { 715 // delete created instance of scaling list since it will be inferred 716 delete activePPS->getScalingList(); 717 718 // infer scaling list 719 activePPS->setScalingList( refPps->getScalingList() ); 720 } 721 722 } 723 #endif 620 724 621 725 if( pps->getDependentSliceSegmentsEnabledFlag() ) … … 670 774 m_cSAO.destroy(); 671 775 #if REPN_FORMAT_IN_VPS 776 #if AUXILIARY_PICTURES 777 #if HM_CLEANUP_SAO 778 m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); 779 #else 672 780 m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight() ); 781 #endif 782 #else 783 #if HM_CLEANUP_SAO 784 m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); 785 #else 786 m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight() ); 787 #endif 788 #endif 789 #else 790 #if HM_CLEANUP_SAO 791 m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); 673 792 #else 674 793 m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight() ); 794 #endif 675 795 #endif 676 796 m_cLoopFilter.create( sps->getMaxCUDepth() ); … … 688 808 { 689 809 TComPic*& pcPic = m_pcPic; 810 #if NO_CLRAS_OUTPUT_FLAG 811 Bool bFirstSliceInSeq; 812 #endif 690 813 #if SVC_EXTENSION 691 m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder[m_layerId].getPrefetchedVPS(0) ); 814 m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder.getPrefetchedVPS(0) ); 815 #if OUTPUT_LAYER_SET_INDEX 816 // Following check should go wherever the VPS is activated 817 checkValueOfOutputLayerSetIdx( m_apcSlicePilot->getVPS()); 818 #endif 692 819 m_apcSlicePilot->initSlice( nalu.m_layerId ); 693 820 #else … … 727 854 m_apcSlicePilot->setNumSamplePredRefLayers( getNumSamplePredRefLayers() ); 728 855 #endif 729 m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder[m_layerId]); 730 #else 856 #endif 731 857 m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder); 732 #endif733 858 734 859 // set POC for dependent slices in skipped pictures … … 788 913 // actual decoding starts here 789 914 xActivateParameterSets(); 790 #if !O0223_O0139_IRAP_ALIGN_NO_CONTRAINTS 915 #if !O0223_O0139_IRAP_ALIGN_NO_CONTRAINTS && N0147_IRAP_ALIGN_FLAG 791 916 //Note setting O0223_O0139_IRAP_ALIGN_NO_CONTRAINTS to 0 may cause decoder to crash. 792 917 //When cross_layer_irap_aligned_flag is equal to 0, num_extra_slice_header_bits >=1 … … 801 926 } 802 927 #endif 803 804 928 #if REPN_FORMAT_IN_VPS 805 929 // Initialize ILRP if needed, only for the current layer … … 816 940 #endif 817 941 } 942 #if NO_CLRAS_OUTPUT_FLAG 943 bFirstSliceInSeq = m_bFirstSliceInSequence; 944 #endif 818 945 m_bFirstSliceInSequence = false; 819 946 #if POC_RESET_FLAG … … 829 956 Int pocAdjustValue = m_apcSlicePilot->getPOC(); 830 957 958 #if PREVTID0_POC_RESET 959 m_apcSlicePilot->adjustPrevTid0POC(pocAdjustValue); 960 #endif 831 961 // If poc reset flag is set to 1, reset all POC for DPB -> basically do it for each slice in the picutre 832 962 TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); … … 882 1012 // Check for TSA alignment 883 1013 if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || 884 m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_T LA_R1014 m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R 885 1015 ) 886 1016 { … … 892 1022 { 893 1023 assert( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || 894 m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_T LA_R ); // TSA pictures should be aligned among depenedent layers1024 m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R ); // TSA pictures should be aligned among depenedent layers 895 1025 } 896 1026 } … … 924 1054 { 925 1055 #if AVC_BASE 926 if( m_layerId == 1 && m_parameterSetManagerDecoder [0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() )1056 if( m_layerId == 1 && m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) 927 1057 { 928 1058 TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); 1059 pBLPic->getSlice(0)->setReferenced(true); 929 1060 fstream* pFile = m_ppcTDecTop[0]->getBLReconFile(); 930 1061 UInt uiWidth = pBLPic->getPicYuvRec()->getWidth(); … … 973 1104 #endif 974 1105 1106 #if NO_CLRAS_OUTPUT_FLAG 1107 if (m_layerId == 0 && 1108 (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 1109 || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 1110 || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP 1111 || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL 1112 || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP 1113 || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) 1114 { 1115 if (bFirstSliceInSeq) 1116 { 1117 setNoClrasOutputFlag(true); 1118 } 1119 else if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 1120 || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 1121 || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP) 1122 { 1123 setNoClrasOutputFlag(true); 1124 } 1125 #if O0149_CROSS_LAYER_BLA_FLAG 1126 else if ((m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP) && 1127 m_apcSlicePilot->getCrossLayerBLAFlag()) 1128 { 1129 setNoClrasOutputFlag(true); 1130 } 1131 #endif 1132 else 1133 { 1134 setNoClrasOutputFlag(false); 1135 } 1136 if (getNoClrasOutputFlag()) 1137 { 1138 for (UInt i = 0; i < m_apcSlicePilot->getVPS()->getMaxLayers(); i++) 1139 { 1140 m_ppcTDecTop[i]->setLayerInitializedFlag(false); 1141 m_ppcTDecTop[i]->setFirstPicInLayerDecodedFlag(false); 1142 } 1143 } 1144 } 1145 #endif 1146 1147 #if NO_CLRAS_OUTPUT_FLAG 1148 m_apcSlicePilot->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, m_cListPic, getNoClrasOutputFlag()); 1149 #endif 1150 975 1151 // Buffer initialize for prediction. 976 1152 m_cPrediction.initTempBuff(); … … 1143 1319 if (m_layerId == 0) 1144 1320 #endif 1145 #if FIX10711146 1321 pcSlice->setRefPicList( m_cListPic, true ); 1147 #else1148 pcSlice->setRefPicList( m_cListPic );1149 #endif1150 1322 1151 1323 #if SVC_EXTENSION … … 1154 1326 if( m_layerId > 0 && m_uiSliceIdx == 0 ) 1155 1327 { 1328 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 1329 if( !pcSlice->getVPS()->getSingleLayerForNonIrapFlag() || ( pcSlice->getVPS()->getSingleLayerForNonIrapFlag() && pcSlice->isIRAP() ) ) 1330 #endif 1156 1331 for( i = 0; i < pcSlice->getNumILRRefIdx(); i++ ) 1157 1332 { 1158 1333 UInt refLayerIdc = i; 1159 1334 #if AVC_BASE 1160 if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder[0].getActiveVPS()->getAvcBaseLayerFlag() ) 1335 if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getAvcBaseLayerFlag() ) 1336 { 1337 TComPic* pic = *m_ppcTDecTop[0]->getListPic()->begin(); 1338 1339 if( pic ) 1340 { 1341 pcSlice->setBaseColPic ( refLayerIdc, pic ); 1342 } 1343 else 1344 { 1345 continue; 1346 } 1347 #if AVC_SYNTAX 1348 TComPic* pBLPic = pcSlice->getBaseColPic(refLayerIdc); 1349 if( pcSlice->getPOC() == 0 ) 1350 { 1351 // initialize partition order. 1352 UInt* piTmp = &g_auiZscanToRaster[0]; 1353 initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp ); 1354 initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 ); 1355 } 1356 pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice ); 1357 pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES ); 1358 #endif 1359 } 1360 else 1361 { 1362 #if VPS_EXTN_DIRECT_REF_LAYERS 1363 TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); 1364 #else 1365 TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); 1366 #endif 1367 TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); 1368 if( !pcSlice->setBaseColPic ( *cListPic, refLayerIdc ) ) 1369 { 1370 continue; 1371 } 1372 } 1373 #else 1374 #if VPS_EXTN_DIRECT_REF_LAYERS 1375 TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); 1376 #else 1377 TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); 1378 #endif 1379 TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); 1380 pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); 1381 #endif 1382 1383 #if O0098_SCALED_REF_LAYER_ID 1384 const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc)); 1385 #else 1386 const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc); 1387 #endif 1388 1389 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(); 1390 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(); 1391 1392 Int widthEL = pcPic->getPicYuvRec()->getWidth() - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset(); 1393 Int heightEL = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset(); 1394 1395 g_mvScalingFactor[refLayerIdc][0] = widthEL == widthBL ? 4096 : Clip3(-4096, 4095, ((widthEL << 8) + (widthBL >> 1)) / widthBL); 1396 g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL); 1397 1398 g_posScalingFactor[refLayerIdc][0] = ((widthBL << 16) + (widthEL >> 1)) / widthEL; 1399 g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL; 1400 1401 #if SVC_UPSAMPLING 1402 if( pcPic->isSpatialEnhLayer(refLayerIdc) ) 1403 { 1404 /*#if O0098_SCALED_REF_LAYER_ID 1405 Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc)); 1406 #else 1407 Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc); 1408 #endif*/ 1409 #if O0215_PHASE_ALIGNMENT 1410 #if O0194_JOINT_US_BITSHIFT 1411 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() ); 1412 #else 1413 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() ); 1414 #endif 1415 #else 1416 #if O0194_JOINT_US_BITSHIFT 1417 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL ); 1418 #else 1419 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL ); 1420 #endif 1421 #endif 1422 } 1423 else 1424 { 1425 pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() ); 1426 } 1427 pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) ); 1428 #endif 1429 } 1430 } 1431 1432 if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() ) 1433 { 1434 for( i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1435 { 1436 UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); 1437 #if AVC_BASE 1438 if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getAvcBaseLayerFlag() ) 1161 1439 { 1162 1440 pcSlice->setBaseColPic ( refLayerIdc, *m_ppcTDecTop[0]->getListPic()->begin() ); … … 1194 1472 #endif 1195 1473 1196 const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc);1197 1198 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth();1199 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight();1200 1201 Int widthEL = pcPic->getPicYuvRec()->getWidth() - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();1202 Int heightEL = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset();1203 1204 g_mvScalingFactor[refLayerIdc][0] = widthEL == widthBL ? 4096 : Clip3(-4096, 4095, ((widthEL << 8) + (widthBL >> 1)) / widthBL);1205 g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);1206 1207 g_posScalingFactor[refLayerIdc][0] = ((widthBL << 16) + (widthEL >> 1)) / widthEL;1208 g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;1209 1210 #if SVC_UPSAMPLING1211 if( pcPic->isSpatialEnhLayer(refLayerIdc) )1212 {1213 #if O0215_PHASE_ALIGNMENT1214 #if O0194_JOINT_US_BITSHIFT1215 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );1216 #else1217 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );1218 #endif1219 #else1220 #if O0194_JOINT_US_BITSHIFT1221 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc) );1222 #else1223 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc) );1224 #endif1225 #endif1226 }1227 else1228 {1229 pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() );1230 }1231 pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) );1232 #endif1233 }1234 }1235 1236 if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )1237 {1238 for( i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )1239 {1240 UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i);1241 #if AVC_BASE1242 if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder[0].getActiveVPS()->getAvcBaseLayerFlag() )1243 {1244 pcSlice->setBaseColPic ( refLayerIdc, *m_ppcTDecTop[0]->getListPic()->begin() );1245 #if AVC_SYNTAX1246 TComPic* pBLPic = pcSlice->getBaseColPic(refLayerIdc);1247 if( pcSlice->getPOC() == 0 )1248 {1249 // initialize partition order.1250 UInt* piTmp = &g_auiZscanToRaster[0];1251 initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp );1252 initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 );1253 }1254 pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice );1255 pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );1256 #endif1257 }1258 else1259 {1260 #if VPS_EXTN_DIRECT_REF_LAYERS1261 TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc );1262 #else1263 TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );1264 #endif1265 TComList<TComPic*> *cListPic = pcTDecTop->getListPic();1266 pcSlice->setBaseColPic ( *cListPic, refLayerIdc );1267 }1268 #else1269 #if VPS_EXTN_DIRECT_REF_LAYERS1270 TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc );1271 #else1272 TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );1273 #endif1274 TComList<TComPic*> *cListPic = pcTDecTop->getListPic();1275 pcSlice->setBaseColPic ( *cListPic, refLayerIdc );1276 #endif1277 1278 1474 pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) ); 1279 1475 } … … 1315 1511 1316 1512 #if N0147_IRAP_ALIGN_FLAG 1317 if( m_layerId > 0 && pcSlice->getVPS()->getCrossLayerIrapAlignFlag()) 1318 { 1513 if( m_layerId > 0 && pcSlice->getVPS()->getCrossLayerIrapAlignFlag() ) 1514 { 1515 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 1516 if( !pcSlice->getVPS()->getSingleLayerForNonIrapFlag() || ( pcSlice->getVPS()->getSingleLayerForNonIrapFlag() && pcSlice->isIRAP() ) ) 1517 #endif 1319 1518 for(Int dependentLayerIdx = 0; dependentLayerIdx < pcSlice->getVPS()->getNumDirectRefLayers(m_layerId); dependentLayerIdx++) 1320 1519 { … … 1376 1575 if(pcSlice->getSPS()->getScalingListFlag()) 1377 1576 { 1378 #if IL_SL_SIGNALLING_N03711379 pcSlice->getSPS()->getScalingList()->setLayerId( m_layerId );1380 #endif1381 1382 1577 pcSlice->setScalingList ( pcSlice->getSPS()->getScalingList() ); 1383 1384 1578 if(pcSlice->getPPS()->getScalingListPresentFlag()) 1385 1579 { 1386 #if IL_SL_SIGNALLING_N03711387 pcSlice->getPPS()->getScalingList()->setLayerId( m_layerId );1388 #endif1389 1390 1580 pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList() ); 1391 1581 } 1582 #if SCALINGLIST_INFERRING 1583 if( m_layerId == 0 || ( m_layerId > 0 && !pcSlice->getPPS()->getInferScalingListFlag() && !pcSlice->getSPS()->getInferScalingListFlag() ) ) 1584 #endif 1392 1585 if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag()) 1393 1586 { 1394 #if IL_SL_SIGNALLING_N03711395 pcSlice->setDefaultScalingList( m_layerId );1396 #else1397 1587 pcSlice->setDefaultScalingList(); 1398 #endif1399 1588 } 1400 1589 m_cTrQuant.setScalingListDec(pcSlice->getScalingList()); … … 1403 1592 else 1404 1593 { 1405 #if IL_SL_SIGNALLING_N03711406 m_cTrQuant.setFlatScalingList( m_layerId );1407 #else1408 1594 m_cTrQuant.setFlatScalingList(); 1409 #endif1410 1595 m_cTrQuant.setUseScalingList(false); 1411 1596 } … … 1425 1610 1426 1611 m_cEntropyDecoder.decodeVPS( vps ); 1427 #if SVC_EXTENSION1428 m_parameterSetManagerDecoder[0].storePrefetchedVPS(vps);1429 #else1430 1612 m_parameterSetManagerDecoder.storePrefetchedVPS(vps); 1431 #endif1432 1613 } 1433 1614 … … 1437 1618 #if SVC_EXTENSION 1438 1619 sps->setLayerId(m_layerId); 1439 m_cEntropyDecoder.decodeSPS( sps, &m_parameterSetManagerDecoder [0]);1440 m_parameterSetManagerDecoder [m_layerId].storePrefetchedSPS(sps);1620 m_cEntropyDecoder.decodeSPS( sps, &m_parameterSetManagerDecoder ); 1621 m_parameterSetManagerDecoder.storePrefetchedSPS(sps); 1441 1622 #if !REPN_FORMAT_IN_VPS // ILRP can only be initialized at activation 1442 1623 if(m_numLayer>0) … … 1455 1636 TComPPS* pps = new TComPPS(); 1456 1637 1457 #if IL_SL_SIGNALLING_N03711458 pps->setLayerId( m_layerId);1638 #if SCALINGLIST_INFERRING 1639 pps->setLayerId( m_layerId ); 1459 1640 #endif 1460 1641 1461 1642 m_cEntropyDecoder.decodePPS( pps ); 1462 #if SVC_EXTENSION1463 m_parameterSetManagerDecoder[m_layerId].storePrefetchedPPS( pps );1464 #else1465 1643 m_parameterSetManagerDecoder.storePrefetchedPPS( pps ); 1466 #endif1467 1644 1468 1645 if( pps->getDependentSliceSegmentsEnabledFlag() ) … … 1492 1669 #endif 1493 1670 #if M0043_LAYERS_PRESENT_SEI 1494 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder [m_layerId].getActiveVPS(), m_parameterSetManagerDecoder[m_layerId].getActiveSPS() );1495 #else 1496 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder [m_layerId].getActiveSPS() );1671 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); 1672 #else 1673 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); 1497 1674 #endif 1498 1675 } … … 1500 1677 { 1501 1678 #if M0043_LAYERS_PRESENT_SEI 1502 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder [m_layerId].getActiveVPS(), m_parameterSetManagerDecoder[m_layerId].getActiveSPS() );1503 #else 1504 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder [m_layerId].getActiveSPS() );1679 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); 1680 #else 1681 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); 1505 1682 #endif 1506 1683 SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); … … 1508 1685 { 1509 1686 SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); 1510 m_parameterSetManagerDecoder [m_layerId].applyPrefetchedPS();1687 m_parameterSetManagerDecoder.applyPrefetchedPS(); 1511 1688 assert(seiAps->activeSeqParamSetId.size()>0); 1512 if (! m_parameterSetManagerDecoder[m_layerId].activateSPSWithSEI(seiAps->activeSeqParamSetId[0] ))1689 if( !m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParamSetId[0] ) ) 1513 1690 { 1514 1691 printf ("Warning SPS activation with Active parameter set SEI failed"); … … 1565 1742 xDecodeVPS(); 1566 1743 #if AVC_BASE 1567 if( m_parameterSetManagerDecoder [0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() )1744 if( m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) 1568 1745 { 1569 1746 if( !m_ppcTDecTop[0]->getBLReconFile()->good() ) … … 1591 1768 xDecodeSPS(); 1592 1769 #if AVC_BASE 1593 if( m_parameterSetManagerDecoder [0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() )1770 if( m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) 1594 1771 { 1595 1772 TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); … … 1597 1774 { 1598 1775 // using EL SPS with spsId = 1 1599 TComSPS* sps = m_parameterSetManagerDecoder [nalu.m_layerId].getPrefetchedSPS(1);1776 TComSPS* sps = m_parameterSetManagerDecoder.getPrefetchedSPS(1); 1600 1777 Int numReorderPics[MAX_TLAYER]; 1601 1778 Window &conformanceWindow = sps->getConformanceWindow(); … … 1644 1821 case NAL_UNIT_CODED_SLICE_TRAIL_R: 1645 1822 case NAL_UNIT_CODED_SLICE_TRAIL_N: 1646 case NAL_UNIT_CODED_SLICE_T LA_R:1823 case NAL_UNIT_CODED_SLICE_TSA_R: 1647 1824 case NAL_UNIT_CODED_SLICE_TSA_N: 1648 1825 case NAL_UNIT_CODED_SLICE_STSA_R: … … 1664 1841 #endif 1665 1842 break; 1843 1844 case NAL_UNIT_EOS: 1845 m_associatedIRAPType = NAL_UNIT_INVALID; 1846 m_pocCRA = 0; 1847 m_pocRandomAccess = MAX_INT; 1848 m_prevPOC = MAX_INT; 1849 m_bFirstSliceInPicture = true; 1850 m_bFirstSliceInSequence = true; 1851 m_prevSliceSkipped = false; 1852 m_skippedPOC = 0; 1853 return false; 1854 1855 case NAL_UNIT_ACCESS_UNIT_DELIMITER: 1856 // TODO: process AU delimiter 1857 return false; 1858 1859 case NAL_UNIT_EOB: 1860 return false; 1861 1666 1862 default: 1667 assert ( 1);1863 assert (0); 1668 1864 } 1669 1865 … … 1746 1942 TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdc ) 1747 1943 { 1748 TComVPS* vps = m_parameterSetManagerDecoder [0].getActiveVPS();1944 TComVPS* vps = m_parameterSetManagerDecoder.getActiveVPS(); 1749 1945 if( vps->getNumDirectRefLayers( m_layerId ) <= 0 ) 1750 1946 { … … 1838 2034 } 1839 2035 #endif 1840 2036 #if OUTPUT_LAYER_SET_INDEX 2037 Void TDecTop::checkValueOfOutputLayerSetIdx(TComVPS *vps) 2038 { 2039 CommonDecoderParams* params = this->getCommonDecoderParams(); 2040 if( params->getValueCheckedFlag() ) 2041 { 2042 return; // Already checked 2043 } 2044 if( params->getOutputLayerSetIdx() == -1 ) // Output layer set index not specified 2045 { 2046 Bool layerSetMatchFound = false; 2047 // Output layer set index not assigned. 2048 // Based on the value of targetLayerId, check if any of the output layer matches 2049 // Currently, the target layer ID in the encoder assumes that all the layers are decoded 2050 // Check if any of the output layer sets match this description 2051 for(Int i = 0; i < vps->getNumOutputLayerSets(); i++) 2052 { 2053 Bool layerSetMatchFlag = true; 2054 Int layerSetIdx = vps->getOutputLayerSetIdx( i ); 2055 if( vps->getNumLayersInIdList( layerSetIdx ) == params->getTargetLayerId() + 1 ) 2056 { 2057 for(Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++) 2058 { 2059 if( vps->getLayerSetLayerIdList( layerSetIdx, j ) != j ) 2060 { 2061 layerSetMatchFlag = false; 2062 break; 2063 } 2064 } 2065 } 2066 else 2067 { 2068 layerSetMatchFlag = false; 2069 } 2070 2071 if( layerSetMatchFlag ) // Potential output layer set candidate found 2072 { 2073 // If target dec layer ID list is also included - check if they match 2074 if( params->getTargetDecLayerIdSet() ) 2075 { 2076 if( params->getTargetDecLayerIdSet()->size() ) 2077 { 2078 for(Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++) 2079 { 2080 if( *(params->getTargetDecLayerIdSet()->begin() + j) != vps->getLayerIdInNuh(vps->getLayerSetLayerIdList( layerSetIdx, j ))) 2081 { 2082 layerSetMatchFlag = false; 2083 } 2084 } 2085 } 2086 } 2087 if( layerSetMatchFlag ) // The target dec layer ID list also matches, if present 2088 { 2089 // Match found 2090 layerSetMatchFound = true; 2091 params->setOutputLayerSetIdx( i ); 2092 params->setValueCheckedFlag( true ); 2093 break; 2094 } 2095 } 2096 } 2097 assert( layerSetMatchFound ); // No output layer set matched the value of either targetLayerId or targetdeclayerIdlist 2098 } 2099 else // Output layer set index is assigned - check if the values match 2100 { 2101 // Check if the target decoded layer is the highest layer in the list 2102 Int layerSetIdx = vps->getOutputLayerSetIdx( params->getOutputLayerSetIdx() ); // Index to the layer set 2103 assert( params->getTargetLayerId() == vps->getNumLayersInIdList( layerSetIdx ) - 1); 2104 2105 Bool layerSetMatchFlag = true; 2106 for(Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++) 2107 { 2108 if( vps->getLayerSetLayerIdList( layerSetIdx, j ) != j ) 2109 { 2110 layerSetMatchFlag = false; 2111 break; 2112 } 2113 } 2114 2115 assert(layerSetMatchFlag); // Signaled output layer set index does not match targetOutputLayerId. 2116 2117 // Check if the targetdeclayerIdlist matches the output layer set 2118 if( params->getTargetDecLayerIdSet() ) 2119 { 2120 if( params->getTargetDecLayerIdSet()->size() ) 2121 { 2122 for(Int i = 0; i < vps->getNumLayersInIdList( layerSetIdx ); i++) 2123 { 2124 assert( *(params->getTargetDecLayerIdSet()->begin() + i) == vps->getLayerIdInNuh(vps->getLayerSetLayerIdList( layerSetIdx, i ))); 2125 } 2126 } 2127 } 2128 params->setValueCheckedFlag( true ); 2129 2130 } 2131 } 2132 #endif 1841 2133 //! \} -
trunk/source/Lib/TLibDecoder/TDecTop.h
r494 r540 72 72 73 73 TComList<TComPic*> m_cListPic; // Dynamic buffer 74 #if SVC_EXTENSION75 ParameterSetManagerDecoder m_parameterSetManagerDecoder[MAX_LAYERS]; // storage for parameter sets76 #else77 74 ParameterSetManagerDecoder m_parameterSetManagerDecoder; // storage for parameter sets 78 #endif79 80 75 TComSlice* m_apcSlicePilot; 81 76 … … 134 129 TComPic* m_cIlpPic[MAX_NUM_REF]; ///< Inter layer Prediction picture = upsampled picture 135 130 #endif 131 #if OUTPUT_LAYER_SET_INDEX 132 CommonDecoderParams* m_commonDecoderParams; 133 #endif 136 134 #if AVC_SYNTAX || SYNTAX_OUTPUT 137 135 fstream* m_pBLSyntaxFile; 136 #endif 137 138 #if NO_CLRAS_OUTPUT_FLAG 139 Bool m_noClrasOutputFlag; 140 Bool m_layerInitializedFlag; 141 Bool m_firstPicInLayerDecodedFlag; 142 Bool m_noOutputOfPriorPicsFlags; 143 144 Bool m_bRefreshPending; 138 145 #endif 139 146 … … 241 248 #endif 242 249 250 #if NO_CLRAS_OUTPUT_FLAG 251 Int getNoClrasOutputFlag() { return m_noClrasOutputFlag;} 252 Void setNoClrasOutputFlag(Bool x) { m_noClrasOutputFlag = x; } 253 Int getLayerInitializedFlag() { return m_layerInitializedFlag;} 254 Void setLayerInitializedFlag(Bool x) { m_layerInitializedFlag = x; } 255 Int getFirstPicInLayerDecodedFlag() { return m_firstPicInLayerDecodedFlag;} 256 Void setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x; } 257 Int getNoOutputOfPriorPicsFlags() { return m_noOutputOfPriorPicsFlags;} 258 Void setNoOutputOfPriorPicsFlags(Bool x) { m_noOutputOfPriorPicsFlags = x; } 259 #endif 260 public: 261 #if OUTPUT_LAYER_SET_INDEX 262 CommonDecoderParams* getCommonDecoderParams() { return m_commonDecoderParams; } 263 Void setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; } 264 Void checkValueOfOutputLayerSetIdx(TComVPS *vps); 265 #endif 266 #if SCALINGLIST_INFERRING 267 ParameterSetManagerDecoder* getParameterSetManager() { return &m_parameterSetManagerDecoder; } 268 #endif 243 269 };// END CLASS DEFINITION TDecTop 244 270 -
trunk/source/Lib/TLibEncoder/TEncAnalyze.cpp
r442 r540 58 58 59 59 TEncAnalyze m_gcAnalyzeAll_in; 60 60 61 //! \} -
trunk/source/Lib/TLibEncoder/TEncAnalyze.h
r442 r540 160 160 } 161 161 162 162 163 Void printSummary(Char ch) 163 164 { … … 207 208 208 209 extern TEncAnalyze m_gcAnalyzeAll_in; 210 209 211 //! \} 210 212 -
trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
r494 r540 220 220 } 221 221 } 222 223 #if SCALINGLIST_INFERRING 224 if( pcPPS->getLayerId() > 0 ) 225 { 226 WRITE_FLAG( pcPPS->getInferScalingListFlag() ? 1 : 0, "pps_infer_scaling_list_flag" ); 227 } 228 229 if( pcPPS->getInferScalingListFlag() ) 230 { 231 // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive 232 assert( pcPPS->getScalingListRefLayerId() <= 62 ); 233 234 WRITE_UVLC( pcPPS->getScalingListRefLayerId(), "pps_scaling_list_ref_layer_id" ); 235 } 236 else 237 { 238 #endif 239 222 240 WRITE_FLAG( pcPPS->getScalingListPresentFlag() ? 1 : 0, "pps_scaling_list_data_present_flag" ); 223 224 #if IL_SL_SIGNALLING_N0371225 pcPPS->setPPS( pcPPS->getLayerId(), pcPPS );226 #endif227 228 241 if( pcPPS->getScalingListPresentFlag() ) 229 242 { 230 #if SCALING_LIST_OUTPUT_RESULT231 printf("PPS\n");232 #endif233 234 #if IL_SL_SIGNALLING_N0371235 m_pcSlice->getScalingList()->setLayerId( pcPPS->getLayerId() );236 237 if( pcPPS->getLayerId() > 0 )238 {239 WRITE_FLAG( pcPPS->getPredScalingListFlag() ? 1 : 0, "pps_pred_scaling_list_flag" );240 m_pcSlice->getScalingList()->setPredScalingListFlag( pcPPS->getPredScalingListFlag() );241 242 if( pcPPS->getPredScalingListFlag() )243 {244 // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive245 assert( /*pcPPS->getScalingListRefLayerId() >= 0 &&*/ pcPPS->getScalingListRefLayerId() <= 62 );246 247 // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of pps_scaling_list_ref_layer_id shall be greater than 0248 if( pcPPS->getSPS()->getVPS()->getAvcBaseLayerFlag() )249 {250 assert( pcPPS->getScalingListRefLayerId() > 0 );251 }252 253 // It is a requirement of bitstream conformance that, when a PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and254 // pps_infer_scaling_list_flag in the PPS is equal to 1, pps_infer_scaling_list_flag shall be equal to 0 for the PPS that is active for the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id255 assert( pcPPS->getPPS( pcPPS->getScalingListRefLayerId() )->getPredScalingListFlag() == false );256 257 // It is a requirement of bitstream conformance that, when a PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB,258 // the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB259 assert( pcPPS->getSPS()->getVPS()->getScalingListLayerDependency( pcPPS->getLayerId(), pcPPS->getScalingListRefLayerId() ) == true );260 261 WRITE_UVLC( pcPPS->getScalingListRefLayerId(), "scaling_list_pps_ref_layer_id" );262 m_pcSlice->getScalingList()->setScalingListRefLayerId( pcPPS->getScalingListRefLayerId() );263 codeScalingList( m_pcSlice->getScalingList() );264 }265 else266 {267 codeScalingList( m_pcSlice->getScalingList() );268 }269 }270 else271 {272 codeScalingList( m_pcSlice->getScalingList() );273 }274 #else275 243 codeScalingList( m_pcSlice->getScalingList() ); 276 #endif 277 278 } 244 } 245 246 #if SCALINGLIST_INFERRING 247 } 248 #endif 249 279 250 WRITE_FLAG( pcPPS->getListsModificationPresentFlag(), "lists_modification_present_flag"); 280 251 WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2"); … … 471 442 WRITE_FLAG( pcSPS->getUpdateRepFormatFlag(), "update_rep_format_flag" ); 472 443 } 444 #if O0096_REP_FORMAT_INDEX 445 if( pcSPS->getLayerId() == 0 ) 446 #else 473 447 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 448 #endif 474 449 { 475 450 #endif … … 486 461 #if REPN_FORMAT_IN_VPS 487 462 } 463 #if O0096_REP_FORMAT_INDEX 464 else if (pcSPS->getUpdateRepFormatFlag()) 465 { 466 WRITE_CODE( pcSPS->getUpdateRepFormatIndex(), 8, "update_rep_format_index"); 467 } 468 #endif 488 469 #endif 489 470 Window conf = pcSPS->getConformanceWindow(); … … 499 480 500 481 #if REPN_FORMAT_IN_VPS 482 #if O0096_REP_FORMAT_INDEX 483 if( pcSPS->getLayerId() == 0 ) 484 #else 501 485 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 486 #endif 502 487 { 503 488 assert( pcSPS->getBitDepthY() >= 8 ); … … 532 517 WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthIntra() - 1, "max_transform_hierarchy_depth_intra" ); 533 518 WRITE_FLAG( pcSPS->getScalingListFlag() ? 1 : 0, "scaling_list_enabled_flag" ); 534 535 #if IL_SL_SIGNALLING_N0371536 pcSPS->setSPS( pcSPS->getLayerId(), pcSPS );537 #endif538 539 519 if(pcSPS->getScalingListFlag()) 540 520 { 521 #if SCALINGLIST_INFERRING 522 if( pcSPS->getLayerId() > 0 ) 523 { 524 WRITE_FLAG( pcSPS->getInferScalingListFlag() ? 1 : 0, "sps_infer_scaling_list_flag" ); 525 } 526 527 if( pcSPS->getInferScalingListFlag() ) 528 { 529 // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive 530 assert( pcSPS->getScalingListRefLayerId() <= 62 ); 531 532 WRITE_UVLC( pcSPS->getScalingListRefLayerId(), "sps_scaling_list_ref_layer_id" ); 533 } 534 else 535 { 536 #endif 541 537 WRITE_FLAG( pcSPS->getScalingListPresentFlag() ? 1 : 0, "sps_scaling_list_data_present_flag" ); 542 538 if(pcSPS->getScalingListPresentFlag()) 543 539 { 544 #if SCALING_LIST_OUTPUT_RESULT545 printf("SPS\n");546 #endif547 548 #if IL_SL_SIGNALLING_N0371549 m_pcSlice->getScalingList()->setLayerId( pcSPS->getLayerId() );550 551 if( pcSPS->getLayerId() > 0 )552 {553 WRITE_FLAG( pcSPS->getPredScalingListFlag() ? 1 : 0, "sps_pred_scaling_list_flag" );554 m_pcSlice->getScalingList()->setPredScalingListFlag( pcSPS->getPredScalingListFlag() );555 556 if( pcSPS->getPredScalingListFlag() )557 {558 559 // The value of sps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive560 assert( /*pcSPS->getScalingListRefLayerId() >= 0 &&*/ pcSPS->getScalingListRefLayerId() <= 62 );561 562 // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0563 if( pcSPS->getVPS()->getAvcBaseLayerFlag() )564 {565 assert( pcSPS->getScalingListRefLayerId() > 0 );566 }567 568 // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and569 // sps_infer_scaling_list_flag in the SPS is equal to 1, sps_infer_scaling_list_flag shall be equal to 0 for the SPS that is active for the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id570 assert( pcSPS->getSPS( pcSPS->getScalingListRefLayerId() )->getPredScalingListFlag() == false );571 572 // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB,573 // the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB574 assert( pcSPS->getVPS()->getScalingListLayerDependency( pcSPS->getLayerId(), pcSPS->getScalingListRefLayerId() ) == true );575 576 WRITE_UVLC( pcSPS->getScalingListRefLayerId(), "scaling_list_sps_ref_layer_id" );577 m_pcSlice->getScalingList()->setScalingListRefLayerId( pcSPS->getScalingListRefLayerId() );578 codeScalingList( m_pcSlice->getScalingList() );579 }580 else581 {582 codeScalingList( m_pcSlice->getScalingList() );583 }584 }585 else586 {587 540 codeScalingList( m_pcSlice->getScalingList() ); 588 541 } 589 #else 590 codeScalingList( m_pcSlice->getScalingList() ); 591 #endif 592 593 } 542 #if SCALINGLIST_INFERRING 543 } 544 #endif 594 545 } 595 546 WRITE_FLAG( pcSPS->getUseAMP() ? 1 : 0, "amp_enabled_flag" ); … … 648 599 if( 1 ) // if( sps_extension_flag ) 649 600 { 601 #if O0142_CONDITIONAL_SPS_EXTENSION 602 UInt spsExtensionTypeFlag[8] = { 0, 1, 0, 0, 0, 0, 0, 0 }; 603 for (UInt i = 0; i < 8; i++) 604 { 605 WRITE_FLAG( spsExtensionTypeFlag[i], "sps_extension_type_flag" ); 606 } 607 if (spsExtensionTypeFlag[1]) 608 { 609 codeSPSExtension( pcSPS ); 610 } 611 #else 650 612 codeSPSExtension( pcSPS ); 651 613 WRITE_FLAG( 0, "sps_extension2_flag" ); 614 #endif 652 615 } 653 616 #else … … 670 633 { 671 634 Window scaledWindow = pcSPS->getScaledRefLayerWindow(i); 635 #if O0098_SCALED_REF_LAYER_ID 636 WRITE_CODE( pcSPS->getScaledRefLayerId(i), 6, "scaled_ref_layer_id" ); 637 #endif 672 638 WRITE_SVLC( scaledWindow.getWindowLeftOffset() >> 1, "scaled_ref_layer_left_offset" ); 673 639 WRITE_SVLC( scaledWindow.getWindowTopOffset() >> 1, "scaled_ref_layer_top_offset" ); … … 891 857 } 892 858 } 859 #endif 860 #if VPS_TSLAYERS 861 WRITE_FLAG( vps->getMaxTSLayersPresentFlag(), "vps_sub_layers_max_minus1_present_flag"); 862 if (vps->getMaxTSLayersPresentFlag()) 863 { 864 for( i = 0; i < vps->getMaxLayers() - 1; i++) 865 { 866 WRITE_CODE(vps->getMaxTSLayersMinus1(i), 3, "sub_layers_vps_max_minus1[i]" ); 867 } 868 } 893 869 #endif 894 870 #if JCTVC_M0203_INTERLAYER_PRED_IDC … … 982 958 } 983 959 960 #if O0153_ALT_OUTPUT_LAYER_FLAG 961 if( vps->getMaxLayers() > 1 ) 962 { 963 WRITE_FLAG( vps->getAltOuputLayerFlag(), "alt_output_layer_flag" ); 964 } 965 #endif 966 984 967 #if REPN_FORMAT_IN_VPS 985 968 WRITE_FLAG( vps->getRepFormatIdxPresentFlag(), "rep_format_idx_present_flag"); … … 987 970 if( vps->getRepFormatIdxPresentFlag() ) 988 971 { 972 #if O0096_REP_FORMAT_INDEX 973 WRITE_CODE( vps->getVpsNumRepFormats() - 1, 8, "vps_num_rep_formats_minus1" ); 974 #else 989 975 WRITE_CODE( vps->getVpsNumRepFormats() - 1, 4, "vps_num_rep_formats_minus1" ); 976 #endif 990 977 } 991 978 for(i = 0; i < vps->getVpsNumRepFormats(); i++) … … 1001 988 if( vps->getVpsNumRepFormats() > 1 ) 1002 989 { 990 #if O0096_REP_FORMAT_INDEX 991 WRITE_CODE( vps->getVpsRepFormatIdx(i), 8, "vps_rep_format_idx[i]" ); 992 #else 1003 993 WRITE_CODE( vps->getVpsRepFormatIdx(i), 4, "vps_rep_format_idx[i]" ); 994 #endif 1004 995 } 1005 996 } … … 1025 1016 WRITE_FLAG(vps->getCrossLayerIrapAlignFlag(), "cross_layer_irap_aligned_flag"); 1026 1017 #endif 1018 #if VPS_DPB_SIZE_TABLE 1019 for(i = 1; i < vps->getNumOutputLayerSets(); i++) 1020 { 1021 WRITE_FLAG( vps->getSubLayerFlagInfoPresentFlag( i ), "sub_layer_flag_info_present_flag[i]"); 1022 for(j = 0; j < vps->getMaxTLayers(); j++) 1023 { 1024 if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) ) 1025 { 1026 WRITE_FLAG( vps->getSubLayerDpbInfoPresentFlag( i, j), "sub_layer_dpb_info_present_flag[i]"); 1027 } 1028 if( vps->getSubLayerDpbInfoPresentFlag(i, j) ) 1029 { 1030 for(Int k = 0; k < vps->getNumSubDpbs(i); k++) 1031 { 1032 WRITE_UVLC( vps->getMaxVpsDecPicBufferingMinus1( i, k, j), "max_vps_dec_pic_buffering_minus1[i][k][j]" ); 1033 } 1034 WRITE_UVLC( vps->getMaxVpsNumReorderPics( i, j), "max_vps_num_reorder_pics[i][j]" ); 1035 WRITE_UVLC( vps->getMaxVpsLatencyIncreasePlus1( i, j), "max_vps_latency_increase_plus1[i][j]" ); 1036 } 1037 } 1038 } 1039 #endif 1027 1040 #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS 1028 1041 WRITE_UVLC( vps->getDirectDepTypeLen()-2, "direct_dep_type_len_minus2"); 1042 #if O0096_DEFAULT_DEPENDENCY_TYPE 1043 WRITE_FLAG(vps->getDefaultDirectDependencyTypeFlag(), "default_direct_dependency_flag"); 1044 if (vps->getDefaultDirectDependencyTypeFlag()) 1045 { 1046 WRITE_CODE( vps->getDefaultDirectDependencyType(), vps->getDirectDepTypeLen(), "default_direct_dependency_type" ); 1047 } 1048 else 1049 { 1050 for(i = 1; i < vps->getMaxLayers(); i++) 1051 { 1052 for(j = 0; j < i; j++) 1053 { 1054 if (vps->getDirectDependencyFlag(i, j)) 1055 { 1056 WRITE_CODE( vps->getDirectDependencyType(i, j), vps->getDirectDepTypeLen(), "direct_dependency_type[i][j]" ); 1057 } 1058 } 1059 } 1060 } 1061 #else 1029 1062 for(i = 1; i < vps->getMaxLayers(); i++) 1030 1063 { … … 1037 1070 } 1038 1071 } 1039 1040 #if IL_SL_SIGNALLING_N0371 1041 for(i = 1; i < vps->getMaxLayers(); i++) 1042 { 1043 for(j = 0; j < i; j++) 1044 { 1045 vps->setScalingListLayerDependency( i, j, vps->checkLayerDependency( i,j ) ); 1046 } 1047 } 1048 #endif 1049 1072 #endif 1050 1073 #endif 1051 1074 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 1052 1075 WRITE_FLAG(vps->getSingleLayerForNonIrapFlag(), "single_layer_for_non_irap_flag" ); 1053 1076 #endif 1077 #if HIGHER_LAYER_IRAP_SKIP_FLAG 1078 WRITE_FLAG(vps->getHigherLayerIrapSkipFlag(), "higher_layer_irap_skip_flag" ); 1079 #endif 1054 1080 1055 1081 #if !VPS_VUI … … 1071 1097 Void TEncCavlc::codeRepFormat ( RepFormat *repFormat ) 1072 1098 { 1099 #if REPN_FORMAT_CONTROL_FLAG 1100 WRITE_FLAG ( repFormat->getChromaAndBitDepthVpsPresentFlag(), "chroma_and_bit_depth_vps_presenet_flag"); 1101 1102 WRITE_CODE ( repFormat->getPicWidthVpsInLumaSamples (), 16, "pic_width_in_luma_samples" ); 1103 WRITE_CODE ( repFormat->getPicHeightVpsInLumaSamples(), 16, "pic_height_in_luma_samples" ); 1104 1105 if ( repFormat->getChromaAndBitDepthVpsPresentFlag() ) 1106 { 1107 WRITE_CODE( repFormat->getChromaFormatVpsIdc(), 2, "chroma_format_idc" ); 1108 1109 if( repFormat->getChromaFormatVpsIdc() == 3 ) 1110 { 1111 WRITE_FLAG( repFormat->getSeparateColourPlaneVpsFlag(), "separate_colour_plane_flag"); 1112 } 1113 1114 assert( repFormat->getBitDepthVpsLuma() >= 8 ); 1115 assert( repFormat->getBitDepthVpsChroma() >= 8 ); 1116 WRITE_CODE( repFormat->getBitDepthVpsLuma() - 8, 4, "bit_depth_luma_minus8" ); 1117 WRITE_CODE( repFormat->getBitDepthVpsChroma() - 8, 4, "bit_depth_chroma_minus8" ); 1118 } 1119 #else 1073 1120 WRITE_CODE( repFormat->getChromaFormatVpsIdc(), 2, "chroma_format_idc" ); 1074 1121 … … 1084 1131 assert( repFormat->getBitDepthVpsChroma() >= 8 ); 1085 1132 WRITE_CODE( repFormat->getBitDepthVpsLuma() - 8, 4, "bit_depth_luma_minus8" ); 1086 WRITE_CODE( repFormat->getBitDepthVpsChroma() - 8, 4, "bit_depth_chroma_minus8" ); 1133 WRITE_CODE( repFormat->getBitDepthVpsChroma() - 8, 4, "bit_depth_chroma_minus8" ); 1134 #endif 1087 1135 1088 1136 } … … 1092 1140 { 1093 1141 Int i,j; 1142 #if O0223_PICTURE_TYPES_ALIGN_FLAG 1143 WRITE_FLAG(vps->getCrossLayerPictureTypeAlignFlag(), "cross_layer_pic_type_aligned_flag"); 1144 if (!vps->getCrossLayerPictureTypeAlignFlag()) 1145 { 1146 #endif 1094 1147 #if IRAP_ALIGN_FLAG_IN_VPS_VUI 1095 1148 WRITE_FLAG(vps->getCrossLayerIrapAlignFlag(), "cross_layer_irap_aligned_flag"); 1096 1149 #endif 1150 #if O0223_PICTURE_TYPES_ALIGN_FLAG 1151 } 1152 #endif 1097 1153 #if VPS_VUI_BITRATE_PICRATE 1098 1154 WRITE_FLAG( vps->getBitRatePresentVpsFlag(), "bit_rate_present_vps_flag" ); … … 1127 1183 } 1128 1184 #endif 1185 #if VPS_VUI_TILES_NOT_IN_USE__FLAG 1186 UInt layerIdx; 1187 WRITE_FLAG( vps->getTilesNotInUseFlag() ? 1 : 0 , "tiles_not_in_use_flag" ); 1188 if (!vps->getTilesNotInUseFlag()) 1189 { 1190 for(i = 0; i < vps->getMaxLayers(); i++) 1191 { 1192 WRITE_FLAG( vps->getTilesInUseFlag(i) ? 1 : 0 , "tiles_in_use_flag[ i ]" ); 1193 if (vps->getTilesInUseFlag(i)) 1194 { 1195 WRITE_FLAG( vps->getLoopFilterNotAcrossTilesFlag(i) ? 1 : 0 , "loop_filter_not_across_tiles_flag[ i ]" ); 1196 } 1197 } 1198 #endif 1129 1199 #if TILE_BOUNDARY_ALIGNED_FLAG 1130 for(i = 1; i < vps->getMaxLayers(); i++) 1131 { 1132 for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) 1133 { 1134 WRITE_FLAG( vps->getTileBoundariesAlignedFlag(i,j) ? 1 : 0 , "tile_boundaries_aligned_flag[i][j]" ); 1135 } 1136 } 1137 #endif 1200 for(i = 1; i < vps->getMaxLayers(); i++) 1201 { 1202 for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) 1203 { 1204 #if VPS_VUI_TILES_NOT_IN_USE__FLAG 1205 layerIdx = vps->getLayerIdInVps(vps->getRefLayerId(vps->getLayerIdInNuh(i), j)); 1206 if (vps->getTilesInUseFlag(i) && vps->getTilesInUseFlag(layerIdx)) { 1207 WRITE_FLAG( vps->getTileBoundariesAlignedFlag(i,j) ? 1 : 0 , "tile_boundaries_aligned_flag[i][j]" ); 1208 } 1209 #else 1210 WRITE_FLAG( vps->getTileBoundariesAlignedFlag(i,j) ? 1 : 0 , "tile_boundaries_aligned_flag[i][j]" ); 1211 #endif 1212 } 1213 } 1214 #endif 1215 #if VPS_VUI_TILES_NOT_IN_USE__FLAG 1216 } 1217 #endif 1218 #if VPS_VUI_WPP_NOT_IN_USE__FLAG 1219 WRITE_FLAG( vps->getWppNotInUseFlag() ? 1 : 0 , "wpp_not_in_use_flag" ); 1220 if (!vps->getWppNotInUseFlag()) 1221 { 1222 for(i = 0; i < vps->getMaxLayers(); i++) 1223 { 1224 WRITE_FLAG( vps->getWppInUseFlag(i) ? 1 : 0 , "wpp_in_use_flag[ i ]" ); 1225 } 1226 } 1227 #endif 1138 1228 #if N0160_VUI_EXT_ILP_REF 1139 1229 WRITE_FLAG( vps->getNumIlpRestrictedRefLayers() ? 1 : 0 , "num_ilp_restricted_ref_layers" ); … … 1159 1249 } 1160 1250 #endif 1251 #if VPS_VUI_VIDEO_SIGNAL 1252 WRITE_FLAG( vps->getVideoSigPresentVpsFlag(), "video_signal_info_idx_present_flag" ); 1253 if (vps->getVideoSigPresentVpsFlag()) 1254 { 1255 WRITE_CODE(vps->getNumVideoSignalInfo()-1, 4, "vps_num_video_signal_info_minus1" ); 1256 } 1257 1258 for(i = 0; i < vps->getNumVideoSignalInfo(); i++) 1259 { 1260 WRITE_CODE(vps->getVideoVPSFormat(i), 3, "video_vps_format" ); 1261 WRITE_FLAG(vps->getVideoFullRangeVpsFlag(i), "video_full_range_vps_flag" ); 1262 WRITE_CODE(vps->getColorPrimaries(i), 8, "color_primaries_vps" ); 1263 WRITE_CODE(vps->getTransCharacter(i), 8, "transfer_characteristics_vps" ); 1264 WRITE_CODE(vps->getMaxtrixCoeff(i), 8, "matrix_coeffs_vps" ); 1265 } 1266 1267 if (vps->getVideoSigPresentVpsFlag() && vps->getNumVideoSignalInfo() > 1 ) 1268 { 1269 for (i=1; i < vps->getMaxLayers(); i++) 1270 WRITE_CODE(vps->getVideoSignalInfoIdx(i), 4, "vps_video_signal_info_idx" ); 1271 } 1272 #endif 1161 1273 } 1162 1274 #endif … … 1221 1333 iBits++; 1222 1334 } 1335 #if O0149_CROSS_LAYER_BLA_FLAG 1336 if( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits ) 1337 { 1338 assert(!!"cross_layer_bla_flag"); 1339 WRITE_FLAG(pcSlice->getCrossLayerBLAFlag(), "cross_layer_bla_flag"); 1340 iBits++; 1341 } 1342 #endif 1223 1343 for ( ; iBits < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) 1224 1344 { … … 1299 1419 TComReferencePictureSet* rps = pcSlice->getRPS(); 1300 1420 1301 #if FIX10711302 1421 // check for bitstream restriction stating that: 1303 1422 // If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. … … 1313 1432 } 1314 1433 } 1315 #endif1316 1434 1317 1435 if(pcSlice->getRPSidx() < 0) … … 1467 1585 if (pcSlice->getSPS()->getUseSAO()) 1468 1586 { 1469 WRITE_FLAG( pcSlice->getSaoEnabledFlag(), "slice_sao_luma_flag" ); 1587 WRITE_FLAG( pcSlice->getSaoEnabledFlag(), "slice_sao_luma_flag" ); 1588 #if AUXILIARY_PICTURES 1589 if (pcSlice->getChromaFormatIdc() != CHROMA_400) 1470 1590 { 1591 #endif 1592 #if HM_CLEANUP_SAO 1593 WRITE_FLAG( pcSlice->getSaoEnabledFlagChroma(), "slice_sao_chroma_flag" ); 1594 #else 1595 { 1596 SAOParam *saoParam = pcSlice->getPic()->getPicSym()->getSaoParam(); 1597 WRITE_FLAG( saoParam->bSaoFlag[1], "slice_sao_chroma_flag" ); 1598 } 1599 #endif 1471 1600 #if AUXILIARY_PICTURES 1472 if (pcSlice->getChromaFormatIdc() != CHROMA_400)1473 {1474 #endif1475 SAOParam *saoParam = pcSlice->getPic()->getPicSym()->getSaoParam();1476 WRITE_FLAG( saoParam->bSaoFlag[1], "slice_sao_chroma_flag" );1477 #if AUXILIARY_PICTURES1478 }1479 #endif1480 1601 } 1481 } 1482 } 1602 #endif 1603 } 1604 } 1483 1605 1484 1606 //check if numrefidxes match the defaults. If not, override … … 2026 2148 Bool scalingListPredModeFlag; 2027 2149 2028 #if SCALING_LIST_OUTPUT_RESULT2029 Int startBit;2030 Int startTotalBit;2031 startBit = m_pcBitIf->getNumberOfWrittenBits();2032 startTotalBit = m_pcBitIf->getNumberOfWrittenBits();2033 #endif2034 2035 2150 //for each size 2036 2151 for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) … … 2038 2153 for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) 2039 2154 { 2040 #if SCALING_LIST_OUTPUT_RESULT2041 startBit = m_pcBitIf->getNumberOfWrittenBits();2042 #endif2043 2044 #if IL_SL_SIGNALLING_N03712045 if( scalingList->getLayerId() > 0 && scalingList->getPredScalingListFlag() )2046 {2047 scalingListPredModeFlag = scalingList->checkPredMode( sizeId, listId );2048 WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" );2049 if(!scalingListPredModeFlag)// Copy Mode2050 {2051 WRITE_UVLC( (Int)listId - (Int)scalingList->getRefMatrixId (sizeId,listId), "scaling_list_pred_matrix_id_delta");2052 }2053 else// DPCM Mode2054 {2055 xCodeScalingList(scalingList, sizeId, listId);2056 }2057 }2058 else2059 {2060 scalingListPredModeFlag = scalingList->checkPredMode( sizeId, listId );2061 WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" );2062 if(!scalingListPredModeFlag)// Copy Mode2063 {2064 WRITE_UVLC( (Int)listId - (Int)scalingList->getRefMatrixId (sizeId,listId), "scaling_list_pred_matrix_id_delta");2065 }2066 else// DPCM Mode2067 {2068 xCodeScalingList(scalingList, sizeId, listId);2069 }2070 }2071 #else2072 2155 scalingListPredModeFlag = scalingList->checkPredMode( sizeId, listId ); 2073 2156 WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" ); … … 2080 2163 xCodeScalingList(scalingList, sizeId, listId); 2081 2164 } 2082 #endif 2083 2084 #if SCALING_LIST_OUTPUT_RESULT 2085 printf("Matrix [%d][%d] Bit %d\n",sizeId,listId,m_pcBitIf->getNumberOfWrittenBits() - startBit); 2086 #endif 2087 2088 } 2089 } 2090 #if SCALING_LIST_OUTPUT_RESULT 2091 printf("Total Bit %d\n",m_pcBitIf->getNumberOfWrittenBits()-startTotalBit); 2092 #endif 2165 } 2166 } 2093 2167 return; 2094 2168 } … … 2105 2179 Int data; 2106 2180 Int *src = scalingList->getScalingListAddress(sizeId, listId); 2107 2108 if( sizeId > SCALING_LIST_8x8 ) 2109 { 2110 #if IL_SL_SIGNALLING_N0371 2111 if( scalingList->getLayerId() > 0 && scalingList->getPredScalingListFlag() ) 2112 { 2113 ref_scalingListDC[scalingList->getLayerId()][sizeId][listId] = scalingList->getScalingListDC(sizeId,listId); 2114 scalingList->setScalingListDC(sizeId,listId,ref_scalingListDC[scalingList->getScalingListRefLayerId()][sizeId][listId]); 2115 } 2116 else 2117 { 2118 WRITE_SVLC( scalingList->getScalingListDC(sizeId,listId) - 8, "scaling_list_dc_coef_minus8"); 2119 nextCoef = scalingList->getScalingListDC(sizeId,listId); 2120 ref_scalingListDC[scalingList->getLayerId()][sizeId][listId] = scalingList->getScalingListDC(sizeId,listId); 2121 } 2122 #else 2123 WRITE_SVLC( scalingList->getScalingListDC(sizeId,listId) - 8, "scaling_list_dc_coef_minus8"); 2124 nextCoef = scalingList->getScalingListDC(sizeId,listId); 2125 #endif 2126 } 2127 for(Int i=0;i<coefNum;i++) 2128 { 2129 #if IL_SL_SIGNALLING_N0371 2130 if( scalingList->getLayerId() > 0 && scalingList->getPredScalingListFlag() ) 2131 { 2132 ref_scalingListCoef[scalingList->getLayerId()][sizeId][listId][i] = src[scan[i]]; 2133 src[scan[i]] = ref_scalingListCoef[scalingList->getScalingListRefLayerId()][sizeId][listId][i]; 2134 } 2135 else 2136 { 2137 data = src[scan[i]] - nextCoef; 2138 ref_scalingListCoef[scalingList->getLayerId()][sizeId][listId][i] = src[scan[i]]; 2139 nextCoef = src[scan[i]]; 2140 if(data > 127) 2141 { 2142 data = data - 256; 2143 } 2144 if(data < -128) 2145 { 2146 data = data + 256; 2147 } 2148 2149 WRITE_SVLC( data, "scaling_list_delta_coef"); 2150 } 2151 #else 2152 data = src[scan[i]] - nextCoef; 2153 nextCoef = src[scan[i]]; 2154 if(data > 127) 2155 { 2156 data = data - 256; 2157 } 2158 if(data < -128) 2159 { 2160 data = data + 256; 2161 } 2162 2163 WRITE_SVLC( data, "scaling_list_delta_coef"); 2164 #endif 2165 } 2181 if( sizeId > SCALING_LIST_8x8 ) 2182 { 2183 WRITE_SVLC( scalingList->getScalingListDC(sizeId,listId) - 8, "scaling_list_dc_coef_minus8"); 2184 nextCoef = scalingList->getScalingListDC(sizeId,listId); 2185 } 2186 for(Int i=0;i<coefNum;i++) 2187 { 2188 data = src[scan[i]] - nextCoef; 2189 nextCoef = src[scan[i]]; 2190 if(data > 127) 2191 { 2192 data = data - 256; 2193 } 2194 if(data < -128) 2195 { 2196 data = data + 256; 2197 } 2198 2199 WRITE_SVLC( data, "scaling_list_delta_coef"); 2200 } 2166 2201 } 2167 2202 Bool TEncCavlc::findMatchingLTRP ( TComSlice* pcSlice, UInt *ltrpsIndex, Int ltrpPOC, Bool usedFlag ) -
trunk/source/Lib/TLibEncoder/TEncCavlc.h
r442 r540 109 109 110 110 Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ); 111 #if HM_CLEANUP_SAO 112 Void codeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false){printf("only supported in CABAC"); assert(0); exit(-1);} 113 #else 111 114 Void codeSAOSign ( UInt code ) { printf("Not supported\n"); assert (0); } 112 115 Void codeSaoMaxUvlc ( UInt code, UInt maxSymbol ){printf("Not supported\n"); assert (0);} … … 114 117 Void codeSaoTypeIdx ( UInt uiCode ){printf("Not supported\n"); assert (0);} 115 118 Void codeSaoUflc ( UInt uiLength, UInt uiCode ){ assert(uiCode < 32); printf("Not supported\n"); assert (0);} 116 119 #endif 117 120 Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ); 118 121 Void codeSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); -
trunk/source/Lib/TLibEncoder/TEncCfg.h
r494 r540 196 196 Int m_maxNumOffsetsPerPic; 197 197 Bool m_saoLcuBoundary; 198 #if !HM_CLEANUP_SAO 198 199 Bool m_saoLcuBasedOptimization; 199 200 #endif 200 201 //====== Lossless ======== 201 202 Bool m_useLossless; … … 328 329 Int m_TMVPModeId; 329 330 Int m_signHideFlag; 330 #if RATE_CONTROL_LAMBDA_DOMAIN331 331 Bool m_RCEnableRateControl; 332 332 Int m_RCTargetBitrate; 333 #if M0036_RC_IMPROVEMENT334 333 Int m_RCKeepHierarchicalBit; 335 #else336 Bool m_RCKeepHierarchicalBit;337 #endif338 334 Bool m_RCLCULevelRC; 339 335 Bool m_RCUseLCUSeparateModel; 340 336 Int m_RCInitialQP; 341 337 Bool m_RCForceIntraQP; 342 #else343 Bool m_enableRateCtrl; ///< Flag for using rate control algorithm344 Int m_targetBitrate; ///< target bitrate345 Int m_numLCUInUnit; ///< Total number of LCUs in a frame should be divided by the NumLCUInUnit346 #endif347 338 Bool m_TransquantBypassEnableFlag; ///< transquant_bypass_enable_flag setting in PPS. 348 339 Bool m_CUTransquantBypassFlagValue; ///< if transquant_bypass_enable_flag, the fixed value to use for the per-CU cu_transquant_bypass_flag. … … 393 384 Int m_adaptiveResolutionChange; 394 385 #endif 386 #if O0153_ALT_OUTPUT_LAYER_FLAG 387 Bool m_altOutputLayerFlag; 388 #endif 389 #if HIGHER_LAYER_IRAP_SKIP_FLAG 390 Int m_skipPictureAtArcSwitch; 391 #endif 392 #if O0149_CROSS_LAYER_BLA_FLAG 393 Bool m_crossLayerBLAFlag; 394 #endif 395 395 #endif 396 396 … … 629 629 Void setSaoLcuBoundary (Bool val) { m_saoLcuBoundary = val; } 630 630 Bool getSaoLcuBoundary () { return m_saoLcuBoundary; } 631 #if !HM_CLEANUP_SAO 631 632 Void setSaoLcuBasedOptimization (Bool val) { m_saoLcuBasedOptimization = val; } 632 633 Bool getSaoLcuBasedOptimization () { return m_saoLcuBasedOptimization; } 634 #endif 633 635 Void setLFCrossTileBoundaryFlag ( Bool val ) { m_loopFilterAcrossTilesEnabledFlag = val; } 634 636 Bool getLFCrossTileBoundaryFlag () { return m_loopFilterAcrossTilesEnabledFlag; } … … 806 808 Void setSignHideFlag( Int signHideFlag ) { m_signHideFlag = signHideFlag; } 807 809 Int getSignHideFlag() { return m_signHideFlag; } 808 #if RATE_CONTROL_LAMBDA_DOMAIN809 810 Bool getUseRateCtrl () { return m_RCEnableRateControl; } 810 811 Void setUseRateCtrl ( Bool b ) { m_RCEnableRateControl = b; } 811 812 Int getTargetBitrate () { return m_RCTargetBitrate; } 812 813 Void setTargetBitrate ( Int bitrate ) { m_RCTargetBitrate = bitrate; } 813 #if M0036_RC_IMPROVEMENT814 814 Int getKeepHierBit () { return m_RCKeepHierarchicalBit; } 815 815 Void setKeepHierBit ( Int i ) { m_RCKeepHierarchicalBit = i; } 816 #else817 Bool getKeepHierBit () { return m_RCKeepHierarchicalBit; }818 Void setKeepHierBit ( Bool b ) { m_RCKeepHierarchicalBit = b; }819 #endif820 816 Bool getLCULevelRC () { return m_RCLCULevelRC; } 821 817 Void setLCULevelRC ( Bool b ) { m_RCLCULevelRC = b; } … … 826 822 Bool getForceIntraQP () { return m_RCForceIntraQP; } 827 823 Void setForceIntraQP ( Bool b ) { m_RCForceIntraQP = b; } 828 #else829 Bool getUseRateCtrl () { return m_enableRateCtrl; }830 Void setUseRateCtrl (Bool flag) { m_enableRateCtrl = flag; }831 Int getTargetBitrate () { return m_targetBitrate; }832 Void setTargetBitrate (Int target) { m_targetBitrate = target; }833 Int getNumLCUInUnit () { return m_numLCUInUnit; }834 Void setNumLCUInUnit (Int numLCUs) { m_numLCUInUnit = numLCUs; }835 #endif836 824 Bool getTransquantBypassEnableFlag() { return m_TransquantBypassEnableFlag; } 837 825 Void setTransquantBypassEnableFlag(Bool flag) { m_TransquantBypassEnableFlag = flag; } … … 934 922 Int getAdaptiveResolutionChange() { return m_adaptiveResolutionChange; } 935 923 #endif 924 #if HIGHER_LAYER_IRAP_SKIP_FLAG 925 Void setSkipPictureAtArcSwitch(Int x) { m_skipPictureAtArcSwitch = x; } 926 Int getSkipPictureAtArcSwitch() { return m_skipPictureAtArcSwitch; } 927 #endif 936 928 #if AUXILIARY_PICTURES 937 929 Void setChromaFormatIDC(ChromaFormat x) { m_chromaFormatIDC = x; } 938 930 ChromaFormat getChromaFormatIDC() { return m_chromaFormatIDC; } 939 931 #endif 932 #if O0153_ALT_OUTPUT_LAYER_FLAG 933 Bool getAltOuputLayerFlag() const { return m_altOutputLayerFlag; } 934 Void setAltOuputLayerFlag(Bool b) { m_altOutputLayerFlag = b; } 935 #endif 936 #if O0149_CROSS_LAYER_BLA_FLAG 937 Bool getCrossLayerBLAFlag() const { return m_crossLayerBLAFlag; } 938 Void setCrossLayerBLAFlag(Bool b) { m_crossLayerBLAFlag = b; } 939 #endif 940 940 #endif 941 941 }; -
trunk/source/Lib/TLibEncoder/TEncCu.cpp
r494 r540 95 95 96 96 m_bEncodeDQP = false; 97 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT98 m_LCUPredictionSAD = 0;99 m_addSADDepth = 0;100 m_temporalSAD = 0;101 #endif102 97 103 98 // initialize partition order. … … 243 238 m_ppcBestCU[0]->initCU( rpcCU->getPic(), rpcCU->getAddr() ); 244 239 m_ppcTempCU[0]->initCU( rpcCU->getPic(), rpcCU->getAddr() ); 245 246 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT247 m_addSADDepth = 0;248 m_LCUPredictionSAD = 0;249 m_temporalSAD = 0;250 #endif251 240 252 241 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI … … 433 422 } 434 423 435 #if RATE_CONTROL_LAMBDA_DOMAIN436 424 if ( m_pcEncCfg->getUseRateCtrl() ) 437 425 { … … 439 427 iMaxQP = m_pcRateCtrl->getRCQP(); 440 428 } 441 #else442 if(m_pcEncCfg->getUseRateCtrl())443 {444 Int qp = m_pcRateCtrl->getUnitQP();445 iMinQP = Clip3( MIN_QP, MAX_QP, qp);446 iMaxQP = Clip3( MIN_QP, MAX_QP, qp);447 }448 #endif449 429 450 430 // If slice start or slice end is within this cu... … … 460 440 if(!bSliceEnd && !bSliceStart && bInsidePicture ) 461 441 { 442 #if HIGHER_LAYER_IRAP_SKIP_FLAG 443 if (m_pcEncCfg->getSkipPictureAtArcSwitch() && m_pcEncCfg->getAdaptiveResolutionChange() > 0 && pcSlice->getLayerId() == 1 && pcSlice->getPOC() == m_pcEncCfg->getAdaptiveResolutionChange()) 444 { 445 rpcTempCU->initEstData( uiDepth, iBaseQP ); 446 447 xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode, true ); 448 } 449 else 450 { 451 #endif 462 452 #if (ENCODER_FAST_MODE) 463 453 Bool testInter = true; … … 528 518 } 529 519 } 530 531 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT532 if ( uiDepth <= m_addSADDepth )533 {534 m_LCUPredictionSAD += m_temporalSAD;535 m_addSADDepth = uiDepth;536 }537 #endif538 520 539 521 if(!earlyDetectionSkipMode) … … 779 761 bSubBranch = true; 780 762 } 763 #if HIGHER_LAYER_IRAP_SKIP_FLAG 764 } 765 #endif 781 766 } 782 767 else if(!(bSliceEnd && bInsidePicture)) 783 768 { 784 769 bBoundary = true; 785 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT786 m_addSADDepth++;787 #endif788 770 } 789 771 … … 829 811 iMaxQP = iStartQP; 830 812 } 831 #if RATE_CONTROL_LAMBDA_DOMAIN832 813 if ( m_pcEncCfg->getUseRateCtrl() ) 833 814 { … … 835 816 iMaxQP = m_pcRateCtrl->getRCQP(); 836 817 } 837 #else838 if(m_pcEncCfg->getUseRateCtrl())839 {840 Int qp = m_pcRateCtrl->getUnitQP();841 iMinQP = Clip3( MIN_QP, MAX_QP, qp);842 iMaxQP = Clip3( MIN_QP, MAX_QP, qp);843 }844 #endif845 818 for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) 846 819 { … … 1143 1116 1144 1117 TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); 1118 #if HIGHER_LAYER_IRAP_SKIP_FLAG 1119 if (m_pcEncCfg->getSkipPictureAtArcSwitch() && m_pcEncCfg->getAdaptiveResolutionChange() > 0 && pcSlice->getLayerId() == 1 && pcSlice->getPOC() == m_pcEncCfg->getAdaptiveResolutionChange()) 1120 { 1121 pcCU->setSkipFlagSubParts(true, uiAbsPartIdx, uiDepth); 1122 } 1123 #endif 1145 1124 // If slice start is within this cu... 1146 1125 Bool bSliceStart = pcSlice->getSliceSegmentCurStartCUAddr() > pcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx && … … 1231 1210 } 1232 1211 1233 #if RATE_CONTROL_INTRA1234 1212 Int xCalcHADs8x8_ISlice(Pel *piOrg, Int iStrideOrg) 1235 1213 { … … 1346 1324 return(iSumHad); 1347 1325 } 1348 #endif1349 1326 1350 1327 /** check RD costs for a CU block encoded with merge … … 1353 1330 * \returns Void 1354 1331 */ 1332 #if HIGHER_LAYER_IRAP_SKIP_FLAG 1333 Void TEncCu::xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool *earlyDetectionSkipMode, Bool bUseSkip ) 1334 #else 1355 1335 Void TEncCu::xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool *earlyDetectionSkipMode ) 1336 #endif 1356 1337 { 1357 1338 assert( rpcTempCU->getSlice()->getSliceType() != I_SLICE ); … … 1387 1368 } 1388 1369 1370 #if HIGHER_LAYER_IRAP_SKIP_FLAG 1371 for( UInt uiNoResidual = bUseSkip?1:0; uiNoResidual < iteration; ++uiNoResidual ) 1372 #else 1389 1373 for( UInt uiNoResidual = 0; uiNoResidual < iteration; ++uiNoResidual ) 1374 #endif 1390 1375 { 1391 1376 for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand ) … … 1515 1500 #endif 1516 1501 1517 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT1518 if ( m_pcEncCfg->getUseRateCtrl() && m_pcEncCfg->getLCULevelRC() && ePartSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth )1519 {1520 UInt SAD = m_pcRdCost->getSADPart( g_bitDepthY, m_ppcPredYuvTemp[uhDepth]->getLumaAddr(), m_ppcPredYuvTemp[uhDepth]->getStride(),1521 m_ppcOrigYuv[uhDepth]->getLumaAddr(), m_ppcOrigYuv[uhDepth]->getStride(),1522 rpcTempCU->getWidth(0), rpcTempCU->getHeight(0) );1523 m_temporalSAD = (Int)SAD;1524 }1525 #endif1526 1527 1502 m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false ); 1528 1503 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); … … 1555 1530 1556 1531 m_pcEntropyCoder->resetBits(); 1557 1558 1532 if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) 1559 1533 { … … 1609 1583 1610 1584 m_pcEntropyCoder->resetBits(); 1611 1612 1585 if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) 1613 1586 { -
trunk/source/Lib/TLibEncoder/TEncCu.h
r494 r540 103 103 Bool m_bUseSBACRD; 104 104 TEncRateCtrl* m_pcRateCtrl; 105 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT 106 UInt m_LCUPredictionSAD; 107 Int m_addSADDepth; 108 Int m_temporalSAD; 109 #endif 105 110 106 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 111 107 Bool m_disableILP; … … 128 124 129 125 Void setBitCounter ( TComBitCounter* pcBitCounter ) { m_pcBitCounter = pcBitCounter; } 130 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT131 UInt getLCUPredictionSAD() { return m_LCUPredictionSAD; }132 #endif133 #if RATE_CONTROL_INTRA134 126 Int updateLCUDataISlice ( TComDataCU* pcCU, Int LCUIdx, Int width, Int height ); 135 #endif136 137 127 protected: 138 128 Void finishCU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); … … 146 136 Int xComputeQP ( TComDataCU* pcCU, UInt uiDepth ); 147 137 Void xCheckBestMode ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth ); 148 138 #if HIGHER_LAYER_IRAP_SKIP_FLAG 139 Void xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool *earlyDetectionSkipMode, Bool bUseSkip=false); 140 #else 149 141 Void xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool *earlyDetectionSkipMode); 142 #endif 150 143 151 144 #if AMP_MRG -
trunk/source/Lib/TLibEncoder/TEncEntropy.cpp
r494 r540 51 51 Void TEncEntropy::encodeSliceHeader ( TComSlice* pcSlice ) 52 52 { 53 #if !HM_CLEANUP_SAO 53 54 if (pcSlice->getSPS()->getUseSAO()) 54 55 { … … 59 60 } 60 61 } 61 62 #endif 62 63 m_pcEntropyCoderIf->codeSliceHeader( pcSlice ); 63 64 return; … … 638 639 } 639 640 641 #if !HM_CLEANUP_SAO 640 642 /** Encode SAO Offset 641 643 * \param saoLcuParam SAO LCU paramters … … 731 733 } 732 734 735 #endif 736 733 737 Int TEncEntropy::countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize ) 734 738 { -
trunk/source/Lib/TLibEncoder/TEncEntropy.h
r345 r540 105 105 virtual Void codeCoeffNxN ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) = 0; 106 106 virtual Void codeTransformSkipFlags ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, TextType eTType ) = 0; 107 #if HM_CLEANUP_SAO 108 virtual Void codeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false) =0; 109 #else 107 110 virtual Void codeSAOSign ( UInt code ) = 0; 108 111 virtual Void codeSaoMaxUvlc ( UInt code, UInt maxSymbol ) = 0; … … 110 113 virtual Void codeSaoTypeIdx ( UInt uiCode) = 0; 111 114 virtual Void codeSaoUflc ( UInt uiLength, UInt uiCode ) = 0; 115 #endif 112 116 virtual Void estBit (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType) = 0; 113 117 … … 188 192 189 193 Void estimateBit ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType); 194 #if HM_CLEANUP_SAO 195 Void encodeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail){m_pcEntropyCoderIf->codeSAOBlkParam(saoBlkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail, false);} 196 #else 190 197 Void encodeSaoOffset(SaoLcuParam* saoLcuParam, UInt compIdx); 191 198 Void encodeSaoUnitInterleaving(Int compIdx, Bool saoFlag, Int rx, Int ry, SaoLcuParam* saoLcuParam, Int cuAddrInSlice, Int cuAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp); 199 #endif 192 200 static Int countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize ); 193 201 -
trunk/source/Lib/TLibEncoder/TEncGOP.cpp
r494 r540 635 635 } 636 636 #endif 637 #if O0149_CROSS_LAYER_BLA_FLAG 638 if( m_layerId == 0 && (getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_N_LP) ) 639 { 640 pcSlice->setCrossLayerBLAFlag(m_pcEncTop->getCrossLayerBLAFlag()); 641 } 642 else 643 { 644 pcSlice->setCrossLayerBLAFlag(false); 645 } 646 #endif 647 #if NO_CLRAS_OUTPUT_FLAG 648 if (m_layerId == 0 && 649 (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 650 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 651 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP 652 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL 653 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP 654 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) 655 { 656 if (m_bFirst) 657 { 658 m_pcEncTop->setNoClrasOutputFlag(true); 659 } 660 else if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 661 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 662 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP) 663 { 664 m_pcEncTop->setNoClrasOutputFlag(true); 665 } 666 #if O0149_CROSS_LAYER_BLA_FLAG 667 else if ((pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP) && 668 pcSlice->getCrossLayerBLAFlag()) 669 { 670 m_pcEncTop->setNoClrasOutputFlag(true); 671 } 672 #endif 673 else 674 { 675 m_pcEncTop->setNoClrasOutputFlag(false); 676 } 677 if (m_pcEncTop->getNoClrasOutputFlag()) 678 { 679 for (UInt i = 0; i < m_pcCfg->getNumLayer(); i++) 680 { 681 m_ppcTEncTop[i]->setLayerInitializedFlag(false); 682 m_ppcTEncTop[i]->setFirstPicInLayerDecodedFlag(false); 683 } 684 } 685 } 686 #endif 637 687 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 638 688 if (m_pcEncTop->getAdaptiveResolutionChange() > 0 && m_layerId == 1 && pocCurr > m_pcEncTop->getAdaptiveResolutionChange()) … … 661 711 #endif 662 712 663 #if IL_SL_SIGNALLING_N0371664 m_pcEncTop->getScalingList()->setLayerId( m_layerId );665 #endif666 667 713 pcSlice->setLastIDR(m_iLastIDR); 668 714 pcSlice->setSliceIdx(0); … … 672 718 if(m_pcEncTop->getUseScalingListId() == SCALING_LIST_OFF) 673 719 { 674 #if IL_SL_SIGNALLING_N0371675 m_pcEncTop->getTrQuant()->setFlatScalingList( m_layerId );676 #else677 720 m_pcEncTop->getTrQuant()->setFlatScalingList(); 678 #endif679 721 m_pcEncTop->getTrQuant()->setUseScalingList(false); 680 722 m_pcEncTop->getSPS()->setScalingListPresentFlag(false); … … 683 725 else if(m_pcEncTop->getUseScalingListId() == SCALING_LIST_DEFAULT) 684 726 { 685 #if IL_SL_SIGNALLING_N0371 686 pcSlice->getScalingList()->setLayerId( m_layerId ); 687 #endif 688 689 #if IL_SL_SIGNALLING_N0371 690 pcSlice->setDefaultScalingList ( m_layerId ); 691 #else 727 #if SCALINGLIST_INFERRING 728 // inferring of the scaling list can be moved to the config file 729 UInt refLayerId = 0; 730 if( m_layerId > 0 && !m_pcEncTop->getVPS()->getAvcBaseLayerFlag() && m_pcEncTop->getVPS()->getRecursiveRefLayerFlag( m_layerId, refLayerId ) ) 731 { 732 m_pcEncTop->getSPS()->setInferScalingListFlag( true ); 733 m_pcEncTop->getSPS()->setScalingListRefLayerId( refLayerId ); 734 m_pcEncTop->getSPS()->setScalingListPresentFlag( false ); 735 m_pcEncTop->getPPS()->setInferScalingListFlag( false ); 736 m_pcEncTop->getPPS()->setScalingListPresentFlag( false ); 737 738 // infer the scaling list from the reference layer 739 pcSlice->setScalingList ( m_ppcTEncTop[refLayerId]->getScalingList() ); 740 } 741 else 742 { 743 #endif 692 744 pcSlice->setDefaultScalingList (); 693 #endif694 695 745 m_pcEncTop->getSPS()->setScalingListPresentFlag(false); 696 746 m_pcEncTop->getPPS()->setScalingListPresentFlag(false); 747 748 #if SCALINGLIST_INFERRING 749 } 750 #endif 751 697 752 m_pcEncTop->getTrQuant()->setScalingList(pcSlice->getScalingList()); 698 753 m_pcEncTop->getTrQuant()->setUseScalingList(true); … … 700 755 else if(m_pcEncTop->getUseScalingListId() == SCALING_LIST_FILE_READ) 701 756 { 702 #if IL_SL_SIGNALLING_N0371 703 pcSlice->getScalingList()->setLayerId( m_layerId ); 757 #if SCALINGLIST_INFERRING 758 // inferring of the scaling list can be moved to the config file 759 UInt refLayerId = 0; 760 if( m_layerId > 0 && !m_pcEncTop->getVPS()->getAvcBaseLayerFlag() && m_pcEncTop->getVPS()->getRecursiveRefLayerFlag( m_layerId, refLayerId ) ) 761 { 762 m_pcEncTop->getSPS()->setInferScalingListFlag( true ); 763 m_pcEncTop->getSPS()->setScalingListRefLayerId( refLayerId ); 764 m_pcEncTop->getSPS()->setScalingListPresentFlag( false ); 765 m_pcEncTop->getPPS()->setInferScalingListFlag( false ); 766 m_pcEncTop->getPPS()->setScalingListPresentFlag( false ); 767 768 // infer the scaling list from the reference layer 769 pcSlice->setScalingList ( m_ppcTEncTop[refLayerId]->getScalingList() ); 770 } 771 else 772 { 704 773 #endif 705 774 706 775 if(pcSlice->getScalingList()->xParseScalingList(m_pcCfg->getScalingListFile())) 707 776 { 708 #if IL_SL_SIGNALLING_N0371709 pcSlice->setDefaultScalingList ( m_layerId );710 #else711 777 pcSlice->setDefaultScalingList (); 712 #endif 713 } 714 #if IL_SL_SIGNALLING_N0371 715 pcSlice->getScalingList()->checkDcOfMatrix( m_layerId ); 716 #else 778 } 779 717 780 pcSlice->getScalingList()->checkDcOfMatrix(); 718 #endif719 781 m_pcEncTop->getSPS()->setScalingListPresentFlag(pcSlice->checkDefaultScalingList()); 720 721 #if IL_SL_SIGNALLING_N0371722 if( m_layerId > 0 )723 {724 m_pcEncTop->getSPS()->setPredScalingListFlag (true);725 m_pcEncTop->getSPS()->setScalingListRefLayerId( 0 );726 }727 #endif728 729 782 m_pcEncTop->getPPS()->setScalingListPresentFlag(false); 730 783 731 #if IL_SL_SIGNALLING_N0371 732 if( m_layerId > 0 ) 733 { 734 m_pcEncTop->getPPS()->setPredScalingListFlag (false); 735 m_pcEncTop->getPPS()->setScalingListRefLayerId( 0 ); 736 } 784 #if SCALINGLIST_INFERRING 785 } 737 786 #endif 738 787 … … 783 832 } 784 833 834 #if O0098_SCALED_REF_LAYER_ID 835 const Window &scalEL = m_pcEncTop->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc)); 836 #else 785 837 const Window &scalEL = m_pcEncTop->getScaledRefLayerWindow(refLayerIdc); 838 #endif 786 839 787 840 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(); … … 800 853 if( pcPic->isSpatialEnhLayer(refLayerIdc)) 801 854 { 855 /*#if O0098_SCALED_REF_LAYER_ID 856 Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc)); 857 #else 858 Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc); 859 #endif*/ 802 860 #if O0215_PHASE_ALIGNMENT 803 861 #if O0194_JOINT_US_BITSHIFT 804 m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );805 #else 806 m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );862 m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() ); 863 #else 864 m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() ); 807 865 #endif 808 866 #else 809 867 #if O0194_JOINT_US_BITSHIFT 810 m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc));811 #else 812 m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc));868 m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL ); 869 #else 870 m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL ); 813 871 #endif 814 872 #endif … … 827 885 pcSlice->setInterLayerPredLayerIdc( interLayerPredLayerIdcTmp[i], i ); 828 886 } 887 888 #if !O0225_TID_BASED_IL_RPS_DERIV 829 889 pcSlice->setActiveNumILRRefIdx( activeNumILRRefIdxTmp ); 890 #endif 830 891 if ( pcSlice->getActiveNumILRRefIdx() == 0 ) 831 892 { … … 902 963 903 964 // Do decoding refresh marking if any 965 #if NO_CLRAS_OUTPUT_FLAG 966 pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic, m_pcEncTop->getNoClrasOutputFlag()); 967 #else 904 968 pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic); 969 #endif 905 970 m_pcEncTop->selectReferencePictureSet(pcSlice, pocCurr, iGOPid); 906 971 pcSlice->getRPS()->setNumberOfLongtermPictures(0); 907 972 908 #if FIX1071909 973 if ((pcSlice->checkThatAllRefPicsAreAvailable(rcListPic, pcSlice->getRPS(), false) != 0) || (pcSlice->isIRAP())) 910 974 { 911 975 pcSlice->createExplicitReferencePictureSetFromReference(rcListPic, pcSlice->getRPS(), pcSlice->isIRAP()); 912 976 } 913 #else914 if(pcSlice->checkThatAllRefPicsAreAvailable(rcListPic, pcSlice->getRPS(), false) != 0)915 {916 pcSlice->createExplicitReferencePictureSetFromReference(rcListPic, pcSlice->getRPS());917 }918 #endif919 977 pcSlice->applyReferencePictureSet(rcListPic, pcSlice->getRPS()); 920 978 … … 934 992 { 935 993 if( ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N ) || 936 ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_T LA_R )994 ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R ) 937 995 ) 938 996 { … … 943 1001 else 944 1002 { 945 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_T LA_R );1003 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TSA_R ); 946 1004 } 947 1005 oneRefLayerTSA = true; … … 975 1033 else 976 1034 { 977 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_T LA_R );1035 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TSA_R ); 978 1036 } 979 1037 } … … 986 1044 else 987 1045 { 988 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_T LA_R);1046 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TSA_R); 989 1047 } 990 1048 #endif … … 1356 1414 pcPic->getSlice(pcSlice->getSliceIdx())->setMvdL1ZeroFlag(pcSlice->getMvdL1ZeroFlag()); 1357 1415 1358 #if RATE_CONTROL_LAMBDA_DOMAIN1359 1416 Double lambda = 0.0; 1360 1417 Int actualHeadBits = 0; … … 1389 1446 else if ( frameLevel == 0 ) // intra case, but use the model 1390 1447 { 1391 #if RATE_CONTROL_INTRA1392 1448 m_pcSliceEncoder->calCostSliceI(pcPic); 1393 #endif1394 1449 if ( m_pcCfg->getIntraPeriod() != 1 ) // do not refine allocated bits for all intra case 1395 1450 { 1396 1451 Int bits = m_pcRateCtrl->getRCSeq()->getLeftAverageBits(); 1397 #if RATE_CONTROL_INTRA1398 1452 bits = m_pcRateCtrl->getRCPic()->getRefineBitsForIntra( bits ); 1399 #else1400 bits = m_pcRateCtrl->getRCSeq()->getRefineBitsForIntra( bits );1401 #endif1402 1453 if ( bits < 200 ) 1403 1454 { … … 1408 1459 1409 1460 list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList(); 1410 #if RATE_CONTROL_INTRA1411 1461 m_pcRateCtrl->getRCPic()->getLCUInitTargetBits(); 1412 1462 lambda = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture, pcSlice->getSliceType()); 1413 #else1414 lambda = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture );1415 #endif1416 1463 sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture ); 1417 1464 } … … 1419 1466 { 1420 1467 list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList(); 1421 #if RATE_CONTROL_INTRA1422 1468 lambda = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture, pcSlice->getSliceType()); 1423 #else1424 lambda = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture );1425 #endif1426 1469 sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture ); 1427 1470 } … … 1436 1479 m_pcSliceEncoder->resetQP( pcPic, sliceQP, lambda ); 1437 1480 } 1438 #endif1439 1481 1440 1482 UInt uiNumSlices = 1; … … 1647 1689 1648 1690 // SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas 1691 #if HM_CLEANUP_SAO 1692 if( pcSlice->getSPS()->getUseSAO() && m_pcCfg->getSaoLcuBoundary() ) 1693 { 1694 m_pcSAO->getPreDBFStatistics(pcPic); 1695 } 1696 #else 1649 1697 if( m_pcCfg->getSaoLcuBasedOptimization() && m_pcCfg->getSaoLcuBoundary() ) 1650 1698 { … … 1652 1700 m_pcSAO->calcSaoStatsCu_BeforeDblk( pcPic ); 1653 1701 } 1654 1702 #endif 1655 1703 //-- Loop filter 1656 1704 Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag(); … … 1662 1710 m_pcLoopFilter->loopFilterPic( pcPic ); 1663 1711 1712 #if !HM_CLEANUP_SAO 1664 1713 pcSlice = pcPic->getSlice(0); 1665 1714 if(pcSlice->getSPS()->getUseSAO()) … … 1681 1730 m_pcSAO->createPicSaoInfo(pcPic); 1682 1731 } 1683 1732 #endif 1684 1733 /////////////////////////////////////////////////////////////////////////////////////////////////// File writing 1685 1734 // Set entropy coder … … 1713 1762 writeRBSPTrailingBits(nalu.m_Bitstream); 1714 1763 accessUnit.push_back(new NALUnitEBSP(nalu)); 1715 #if RATE_CONTROL_LAMBDA_DOMAIN1716 1764 actualTotalBits += UInt(accessUnit.back()->m_nalUnitData.str().size()) * 8; 1717 #endif1718 1765 #if SVC_EXTENSION 1719 1766 } … … 1722 1769 #if SVC_EXTENSION 1723 1770 nalu = NALUnit(NAL_UNIT_SPS, 0, m_layerId); 1724 #if IL_SL_SIGNALLING_N03711725 pcSlice->getSPS()->setVPS( pcSlice->getVPS() );1726 #endif1727 1771 #else 1728 1772 nalu = NALUnit(NAL_UNIT_SPS); … … 1753 1797 pcSlice->getSPS()->getVuiParameters()->setHrdParametersPresentFlag( true ); 1754 1798 } 1799 #if O0092_0094_DEPENDENCY_CONSTRAINT 1800 assert( pcSlice->getSPS()->getLayerId() == 0 || pcSlice->getSPS()->getLayerId() == m_layerId || m_pcEncTop->getVPS()->getRecursiveRefLayerFlag(m_layerId, pcSlice->getSPS()->getLayerId()) ); 1801 #endif 1755 1802 m_pcEntropyCoder->encodeSPS(pcSlice->getSPS()); 1756 1803 writeRBSPTrailingBits(nalu.m_Bitstream); 1757 1804 accessUnit.push_back(new NALUnitEBSP(nalu)); 1758 #if RATE_CONTROL_LAMBDA_DOMAIN1759 1805 actualTotalBits += UInt(accessUnit.back()->m_nalUnitData.str().size()) * 8; 1760 #endif1761 1806 1762 1807 #if SVC_EXTENSION … … 1766 1811 #endif 1767 1812 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); 1813 #if O0092_0094_DEPENDENCY_CONSTRAINT 1814 assert( pcSlice->getPPS()->getPPSId() == 0 || pcSlice->getPPS()->getPPSId() == m_layerId || m_pcEncTop->getVPS()->getRecursiveRefLayerFlag(m_layerId, pcSlice->getPPS()->getPPSId()) ); 1815 #endif 1768 1816 m_pcEntropyCoder->encodePPS(pcSlice->getPPS()); 1769 1817 writeRBSPTrailingBits(nalu.m_Bitstream); 1770 1818 accessUnit.push_back(new NALUnitEBSP(nalu)); 1771 #if RATE_CONTROL_LAMBDA_DOMAIN1772 1819 actualTotalBits += UInt(accessUnit.back()->m_nalUnitData.str().size()) * 8; 1773 #endif1774 1820 1775 1821 xCreateLeadingSEIMessages(accessUnit, pcSlice->getSPS()); … … 2091 2137 } 2092 2138 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); 2093 #if RATE_CONTROL_LAMBDA_DOMAIN2094 2139 tmpBitsBeforeWriting = m_pcEntropyCoder->getNumberOfWrittenBits(); 2095 #endif2096 2097 2140 m_pcEntropyCoder->encodeSliceHeader(pcSlice); 2098 2099 #if RATE_CONTROL_LAMBDA_DOMAIN2100 2141 actualHeadBits += ( m_pcEntropyCoder->getNumberOfWrittenBits() - tmpBitsBeforeWriting ); 2101 #endif2102 2142 2103 2143 // is it needed? … … 2220 2260 xAttachSliceDataToNalUnit(nalu, pcBitstreamRedirect); 2221 2261 accessUnit.push_back(new NALUnitEBSP(nalu)); 2222 #if RATE_CONTROL_LAMBDA_DOMAIN2223 2262 actualTotalBits += UInt(accessUnit.back()->m_nalUnitData.str().size()) * 8; 2224 #endif2225 2263 bNALUAlignedWrittenToList = true; 2226 2264 uiOneBitstreamPerSliceLength += nalu.m_Bitstream.getNumberOfWrittenBits(); // length of bitstream after byte-alignment … … 2262 2300 // set entropy coder for RD 2263 2301 m_pcEntropyCoder->setEntropyCoder ( m_pcSbacCoder, pcSlice ); 2302 #if HIGHER_LAYER_IRAP_SKIP_FLAG 2303 if ( pcSlice->getSPS()->getUseSAO() && !( m_pcEncTop->getSkipPictureAtArcSwitch() && m_pcEncTop->getAdaptiveResolutionChange() > 0 && pcSlice->getLayerId() == 1 && pcSlice->getPOC() == m_pcEncTop->getAdaptiveResolutionChange()) ) 2304 #else 2264 2305 if ( pcSlice->getSPS()->getUseSAO() ) 2306 #endif 2265 2307 { 2266 2308 m_pcEntropyCoder->resetEntropy(); 2267 2309 m_pcEntropyCoder->setBitstream( m_pcBitCounter ); 2310 #if HM_CLEANUP_SAO 2311 Bool sliceEnabled[NUM_SAO_COMPONENTS]; 2312 m_pcSAO->initRDOCabacCoder(m_pcEncTop->getRDGoOnSbacCoder(), pcSlice); 2313 m_pcSAO->SAOProcess(pcPic 2314 , sliceEnabled 2315 , pcPic->getSlice(0)->getLambdas() 2316 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 2317 , m_pcCfg->getSaoLcuBoundary() 2318 #endif 2319 ); 2320 m_pcSAO->PCMLFDisableProcess(pcPic); 2321 2322 //assign SAO slice header 2323 for(Int s=0; s< uiNumSlices; s++) 2324 { 2325 pcPic->getSlice(s)->setSaoEnabledFlag(sliceEnabled[SAO_Y]); 2326 assert(sliceEnabled[SAO_Cb] == sliceEnabled[SAO_Cr]); 2327 pcPic->getSlice(s)->setSaoEnabledFlagChroma(sliceEnabled[SAO_Cb]); 2328 } 2329 #else 2268 2330 m_pcSAO->startSaoEnc(pcPic, m_pcEntropyCoder, m_pcEncTop->getRDSbacCoder(), m_pcEncTop->getRDGoOnSbacCoder()); 2269 2331 SAOParam& cSaoParam = *pcSlice->getPic()->getPicSym()->getSaoParam(); 2270 2332 2271 #if SAO_CHROMA_LAMBDA2272 2333 #if SAO_ENCODING_CHOICE 2273 m_pcSAO->SAOProcess(&cSaoParam, pcPic->getSlice(0)->getLambda Luma(), pcPic->getSlice(0)->getLambdaChroma(), pcPic->getSlice(0)->getDepth());2334 m_pcSAO->SAOProcess(&cSaoParam, pcPic->getSlice(0)->getLambdas()[TEXT_LUMA], pcPic->getSlice(0)->getLambdas()[TEXT_CHROMA], pcPic->getSlice(0)->getDepth()); 2274 2335 #else 2275 2336 m_pcSAO->SAOProcess(&cSaoParam, pcPic->getSlice(0)->getLambdaLuma(), pcPic->getSlice(0)->getLambdaChroma()); 2276 #endif2277 #else2278 m_pcSAO->SAOProcess(&cSaoParam, pcPic->getSlice(0)->getLambda());2279 2337 #endif 2280 2338 m_pcSAO->endSaoEnc(); 2281 2339 m_pcSAO->PCMLFDisableProcess(pcPic); 2340 #endif 2282 2341 } 2342 #if !HM_CLEANUP_SAO 2283 2343 #if SAO_RDO 2284 2344 m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder, pcSlice ); 2285 2345 #endif 2346 #endif 2286 2347 processingState = ENCODE_SLICE; 2287 2348 #if !HM_CLEANUP_SAO 2349 #if HIGHER_LAYER_IRAP_SKIP_FLAG 2350 if ( ( m_pcEncTop->getSkipPictureAtArcSwitch() && m_pcEncTop->getAdaptiveResolutionChange() > 0 && pcSlice->getLayerId() == 1 && pcSlice->getPOC() == m_pcEncTop->getAdaptiveResolutionChange()) ) 2351 { 2352 pcSlice->getPic()->getPicSym()->getSaoParam()->bSaoFlag[0]=0; 2353 pcSlice->getPic()->getPicSym()->getSaoParam()->bSaoFlag[1]=0; 2354 } 2355 #endif 2288 2356 for(Int s=0; s< uiNumSlices; s++) 2289 2357 { … … 2293 2361 } 2294 2362 } 2363 #endif 2295 2364 } 2296 2365 break; … … 2303 2372 } 2304 2373 } // end iteration over slices 2305 2374 #if !HM_CLEANUP_SAO 2306 2375 if(pcSlice->getSPS()->getUseSAO()) 2307 2376 { … … 2312 2381 pcPic->destroyNonDBFilterInfo(); 2313 2382 } 2314 2383 #endif 2315 2384 pcPic->compressMotion(); 2316 2385 … … 2412 2481 } 2413 2482 } 2414 #if RATE_CONTROL_LAMBDA_DOMAIN2415 2483 if ( m_pcCfg->getUseRateCtrl() ) 2416 2484 { 2417 #if !M0036_RC_IMPROVEMENT2418 Double effectivePercentage = m_pcRateCtrl->getRCPic()->getEffectivePercentage();2419 #endif2420 2485 Double avgQP = m_pcRateCtrl->getRCPic()->calAverageQP(); 2421 2486 Double avgLambda = m_pcRateCtrl->getRCPic()->calAverageLambda(); … … 2424 2489 avgLambda = lambda; 2425 2490 } 2426 #if M0036_RC_IMPROVEMENT2427 #if RATE_CONTROL_INTRA2428 2491 m_pcRateCtrl->getRCPic()->updateAfterPicture( actualHeadBits, actualTotalBits, avgQP, avgLambda, pcSlice->getSliceType()); 2429 #else2430 m_pcRateCtrl->getRCPic()->updateAfterPicture( actualHeadBits, actualTotalBits, avgQP, avgLambda );2431 #endif2432 #else2433 m_pcRateCtrl->getRCPic()->updateAfterPicture( actualHeadBits, actualTotalBits, avgQP, avgLambda, effectivePercentage );2434 #endif2435 2492 m_pcRateCtrl->getRCPic()->addToPictureLsit( m_pcRateCtrl->getPicList() ); 2436 2493 … … 2445 2502 } 2446 2503 } 2447 #else2448 if(m_pcCfg->getUseRateCtrl())2449 {2450 UInt frameBits = m_vRVM_RP[m_vRVM_RP.size()-1];2451 m_pcRateCtrl->updataRCFrameStatus((Int)frameBits, pcSlice->getSliceType());2452 }2453 #endif2454 2504 2455 2505 if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) && … … 2636 2686 delete[] pcSubstreamsOut; 2637 2687 } 2638 #if !RATE_CONTROL_LAMBDA_DOMAIN2639 if(m_pcCfg->getUseRateCtrl())2640 {2641 m_pcRateCtrl->updateRCGOPStatus();2642 }2643 #endif2644 2688 delete pcBitstreamRedirect; 2645 2689 … … 2724 2768 m_pcEntropyCoder->resetEntropy (); 2725 2769 m_pcEntropyCoder->setBitstream ( m_pcBitCounter ); 2770 #if !HM_CLEANUP_SAO 2726 2771 pcSlice = pcPic->getSlice(0); 2727 2772 if(pcSlice->getSPS()->getUseSAO()) … … 2738 2783 pcPic->destroyNonDBFilterInfo(); 2739 2784 } 2740 2785 #endif 2741 2786 m_pcEntropyCoder->resetEntropy (); 2742 2787 ruiBits += m_pcEntropyCoder->getNumberOfWrittenBits(); … … 2810 2855 iterPicYuvRec--; 2811 2856 } 2857 2812 2858 } 2813 2859 … … 2905 2951 case NAL_UNIT_CODED_SLICE_TRAIL_R: return "TRAIL_R"; 2906 2952 case NAL_UNIT_CODED_SLICE_TRAIL_N: return "TRAIL_N"; 2907 case NAL_UNIT_CODED_SLICE_T LA_R: return "TLA_R";2953 case NAL_UNIT_CODED_SLICE_TSA_R: return "TSA_R"; 2908 2954 case NAL_UNIT_CODED_SLICE_TSA_N: return "TSA_N"; 2909 2955 case NAL_UNIT_CODED_SLICE_STSA_R: return "STSA_R"; … … 3140 3186 for (Int x = 0; x < width; x++) 3141 3187 { 3142 dst[x] = isTff ? (UChar) top[x] : (UChar)bottom[x];3143 dst[stride+x] = isTff ? (UChar) bottom[x] : (UChar)top[x];3188 dst[x] = isTff ? top[x] : bottom[x]; 3189 dst[stride+x] = isTff ? bottom[x] : top[x]; 3144 3190 } 3145 3191 top += stride; … … 3298 3344 delete pcRecInterlaced; 3299 3345 } 3346 3347 3300 3348 3301 3349 /** Function for deciding the nal_unit_type. -
trunk/source/Lib/TLibEncoder/TEncRateCtrl.cpp
r313 r540 42 42 using namespace std; 43 43 44 #if RATE_CONTROL_LAMBDA_DOMAIN45 46 44 //sequence level 47 45 TEncRCSeq::TEncRCSeq() … … 67 65 m_bitsLeft = 0; 68 66 m_useLCUSeparateModel = false; 69 #if M0036_RC_IMPROVEMENT70 67 m_adaptiveBit = 0; 71 68 m_lastLambda = 0.0; 72 #endif73 69 } 74 70 … … 78 74 } 79 75 80 #if M0036_RC_IMPROVEMENT81 76 Void TEncRCSeq::create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel, Int adaptiveBit ) 82 #else83 Void TEncRCSeq::create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel )84 #endif85 77 { 86 78 destroy(); … … 109 101 m_betaUpdate = 0.025; 110 102 } 111 #if M0036_RC_IMPROVEMENT112 103 else if ( m_seqTargetBpp < 0.2 ) 113 104 { … … 125 116 m_betaUpdate = 0.2; 126 117 } 127 #else128 else129 {130 m_alphaUpdate = 0.1;131 m_betaUpdate = 0.05;132 }133 #endif134 118 m_averageBits = (Int)(m_targetBits / totalFrames); 135 119 Int picWidthInBU = ( m_picWidth % m_LCUWidth ) == 0 ? m_picWidth / m_LCUWidth : m_picWidth / m_LCUWidth + 1; … … 172 156 m_framesLeft = m_totalFrames; 173 157 m_bitsLeft = m_targetBits; 174 #if M0036_RC_IMPROVEMENT175 158 m_adaptiveBit = adaptiveBit; 176 159 m_lastLambda = 0.0; 177 #endif178 160 } 179 161 … … 233 215 for ( Int i=0; i<m_numberOfLevel; i++ ) 234 216 { 235 #if RATE_CONTROL_INTRA236 217 if (i>0) 237 218 { … … 244 225 m_picPara[i].m_beta = BETA2; 245 226 } 246 #else247 m_picPara[i].m_alpha = 3.2003;248 m_picPara[i].m_beta = -1.367;249 #endif250 227 } 251 228 } … … 271 248 for ( Int j=0; j<m_numberOfLCU; j++) 272 249 { 273 #if RATE_CONTROL_INTRA274 250 m_LCUPara[i][j].m_alpha = m_picPara[i].m_alpha; 275 251 m_LCUPara[i][j].m_beta = m_picPara[i].m_beta; 276 #else277 m_LCUPara[i][j].m_alpha = 3.2003;278 m_LCUPara[i][j].m_beta = -1.367;279 #endif280 252 } 281 253 } … … 299 271 } 300 272 301 #if !RATE_CONTROL_INTRA302 Int TEncRCSeq::getRefineBitsForIntra( Int orgBits )303 {304 Double bpp = ( (Double)orgBits ) / m_picHeight / m_picHeight;305 if ( bpp > 0.2 )306 {307 return orgBits * 5;308 }309 if ( bpp > 0.1 )310 {311 return orgBits * 7;312 }313 return orgBits * 10;314 }315 #endif316 317 #if M0036_RC_IMPROVEMENT318 273 Void TEncRCSeq::setAllBitRatio( Double basicLambda, Double* equaCoeffA, Double* equaCoeffB ) 319 274 { … … 326 281 delete[] bitsRatio; 327 282 } 328 #endif329 283 330 284 //GOP level … … 349 303 Int targetBits = xEstGOPTargetBits( encRCSeq, numPic ); 350 304 351 #if M0036_RC_IMPROVEMENT352 305 if ( encRCSeq->getAdaptiveBits() > 0 && encRCSeq->getLastLambda() > 0.1 ) 353 306 { … … 409 362 delete []equaCoeffB; 410 363 } 411 #endif412 364 413 365 m_picTargetBitInGOP = new Int[numPic]; … … 422 374 { 423 375 currPicRatio = encRCSeq->getBitRatio( i ); 424 #if M0036_RC_IMPROVEMENT425 376 m_picTargetBitInGOP[i] = (Int)( ((Double)targetBits) * currPicRatio / totalPicRatio ); 426 #else427 m_picTargetBitInGOP[i] = targetBits * currPicRatio / totalPicRatio;428 #endif429 377 } 430 378 … … 436 384 } 437 385 438 #if M0036_RC_IMPROVEMENT439 386 Void TEncRCGOP::xCalEquaCoeff( TEncRCSeq* encRCSeq, Double* lambdaRatio, Double* equaCoeffA, Double* equaCoeffB, Int GOPSize ) 440 387 { … … 482 429 return solution; 483 430 } 484 #endif485 431 486 432 Void TEncRCGOP::destroy() … … 534 480 535 481 m_LCUs = NULL; 536 #if !M0036_RC_IMPROVEMENT537 m_lastPicture = NULL;538 #endif539 482 m_picActualHeaderBits = 0; 540 #if !M0036_RC_IMPROVEMENT541 m_totalMAD = 0.0;542 #endif543 483 m_picActualBits = 0; 544 484 m_picQP = 0; … … 565 505 } 566 506 567 #if M0036_RC_IMPROVEMENT568 507 targetBits = Int( ((Double)GOPbitsLeft) * currPicRatio / totalPicRatio ); 569 #else570 targetBits = Int( GOPbitsLeft * currPicRatio / totalPicRatio );571 #endif572 508 573 509 if ( targetBits < 100 ) … … 665 601 m_LCUs[LCUIdx].m_lambda = 0.0; 666 602 m_LCUs[LCUIdx].m_targetBits = 0; 667 #if M0036_RC_IMPROVEMENT668 603 m_LCUs[LCUIdx].m_bitWeight = 1.0; 669 #else670 m_LCUs[LCUIdx].m_MAD = 0.0;671 #endif672 604 Int currWidth = ( (i == picWidthInLCU -1) ? picWidth - LCUWidth *(picWidthInLCU -1) : LCUWidth ); 673 605 Int currHeight = ( (j == picHeightInLCU-1) ? picHeight - LCUHeight*(picHeightInLCU-1) : LCUHeight ); … … 676 608 } 677 609 m_picActualHeaderBits = 0; 678 #if !M0036_RC_IMPROVEMENT679 m_totalMAD = 0.0;680 #endif681 610 m_picActualBits = 0; 682 611 m_picQP = 0; 683 612 m_picLambda = 0.0; 684 685 #if !M0036_RC_IMPROVEMENT686 m_lastPicture = NULL;687 list<TEncRCPic*>::reverse_iterator it;688 for ( it = listPreviousPictures.rbegin(); it != listPreviousPictures.rend(); it++ )689 {690 if ( (*it)->getFrameLevel() == m_frameLevel )691 {692 m_lastPicture = (*it);693 break;694 }695 }696 #endif697 613 } 698 614 … … 709 625 710 626 711 #if RATE_CONTROL_INTRA712 627 Double TEncRCPic::estimatePicLambda( list<TEncRCPic*>& listPreviousPictures, SliceType eSliceType) 713 #else714 Double TEncRCPic::estimatePicLambda( list<TEncRCPic*>& listPreviousPictures )715 #endif716 628 { 717 629 Double alpha = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha; 718 630 Double beta = m_encRCSeq->getPicPara( m_frameLevel ).m_beta; 719 631 Double bpp = (Double)m_targetBits/(Double)m_numberOfPixel; 720 #if RATE_CONTROL_INTRA721 632 Double estLambda; 722 633 if (eSliceType == I_SLICE) … … 728 639 estLambda = alpha * pow( bpp, beta ); 729 640 } 730 #else731 Double estLambda = alpha * pow( bpp, beta );732 #endif733 641 734 642 Double lastLevelLambda = -1.0; … … 778 686 m_estPicLambda = estLambda; 779 687 780 #if M0036_RC_IMPROVEMENT781 688 Double totalWeight = 0.0; 782 689 // initial BU bit allocation weight 783 690 for ( Int i=0; i<m_numberOfLCU; i++ ) 784 691 { 785 #if RC_FIX786 692 Double alphaLCU, betaLCU; 787 693 if ( m_encRCSeq->getUseLCUSeparateModel() ) … … 795 701 betaLCU = m_encRCSeq->getPicPara( m_frameLevel ).m_beta; 796 702 } 797 #else798 Double alphaLCU = m_encRCSeq->getLCUPara( m_frameLevel, i ).m_alpha;799 Double betaLCU = m_encRCSeq->getLCUPara( m_frameLevel, i ).m_beta;800 #endif801 703 802 704 m_LCUs[i].m_bitWeight = m_LCUs[i].m_numberOfPixel * pow( estLambda/alphaLCU, 1.0/betaLCU ); … … 813 715 m_LCUs[i].m_bitWeight = BUTargetBits; 814 716 } 815 #endif816 717 817 718 return estLambda; … … 856 757 } 857 758 858 #if RATE_CONTROL_INTRA859 759 Double TEncRCPic::getLCUTargetBpp(SliceType eSliceType) 860 #else861 Double TEncRCPic::getLCUTargetBpp()862 #endif863 760 { 864 761 Int LCUIdx = getLCUCoded(); 865 762 Double bpp = -1.0; 866 763 Int avgBits = 0; 867 #if !M0036_RC_IMPROVEMENT 868 Double totalMAD = -1.0; 869 Double MAD = -1.0; 870 #endif 871 872 #if RATE_CONTROL_INTRA 873 if (eSliceType == I_SLICE){ 764 765 if (eSliceType == I_SLICE) 766 { 874 767 Int noOfLCUsLeft = m_numberOfLCU - LCUIdx + 1; 875 768 Int bitrateWindow = min(4,noOfLCUsLeft); … … 889 782 else 890 783 { 891 #endif892 #if M0036_RC_IMPROVEMENT893 784 Double totalWeight = 0; 894 785 for ( Int i=LCUIdx; i<m_numberOfLCU; i++ ) … … 898 789 Int realInfluenceLCU = min( g_RCLCUSmoothWindowSize, getLCULeft() ); 899 790 avgBits = (Int)( m_LCUs[LCUIdx].m_bitWeight - ( totalWeight - m_bitsLeft ) / realInfluenceLCU + 0.5 ); 900 #else 901 if ( m_lastPicture == NULL ) 902 { 903 avgBits = Int( m_bitsLeft / m_LCULeft ); 904 } 905 else 906 { 907 MAD = m_lastPicture->getLCU(LCUIdx).m_MAD; 908 totalMAD = m_lastPicture->getTotalMAD(); 909 for ( Int i=0; i<LCUIdx; i++ ) 910 { 911 totalMAD -= m_lastPicture->getLCU(i).m_MAD; 912 } 913 914 if ( totalMAD > 0.1 ) 915 { 916 avgBits = Int( m_bitsLeft * MAD / totalMAD ); 917 } 918 else 919 { 920 avgBits = Int( m_bitsLeft / m_LCULeft ); 921 } 922 } 923 #endif 924 #if RATE_CONTROL_INTRA 925 } 926 #endif 791 } 927 792 928 793 if ( avgBits < 1 ) … … 1050 915 beta *= ( 1.0 - m_encRCSeq->getBetaUpdate() / 2.0 ); 1051 916 1052 #if M0036_RC_IMPROVEMENT1053 917 alpha = Clip3( g_RCAlphaMinValue, g_RCAlphaMaxValue, alpha ); 1054 918 beta = Clip3( g_RCBetaMinValue, g_RCBetaMaxValue, beta ); 1055 #else1056 alpha = Clip3( 0.05, 20.0, alpha );1057 beta = Clip3( -3.0, -0.1, beta );1058 #endif1059 919 1060 920 TRCParameter rcPara; … … 1069 929 alpha += m_encRCSeq->getAlphaUpdate() * ( log( inputLambda ) - log( calLambda ) ) * alpha; 1070 930 double lnbpp = log( bpp ); 1071 #if M0036_RC_IMPROVEMENT1072 931 lnbpp = Clip3( -5.0, -0.1, lnbpp ); 1073 #else1074 lnbpp = Clip3( -5.0, 1.0, lnbpp );1075 #endif1076 932 beta += m_encRCSeq->getBetaUpdate() * ( log( inputLambda ) - log( calLambda ) ) * lnbpp; 1077 933 1078 #if M0036_RC_IMPROVEMENT1079 934 alpha = Clip3( g_RCAlphaMinValue, g_RCAlphaMaxValue, alpha ); 1080 935 beta = Clip3( g_RCBetaMinValue, g_RCBetaMaxValue, beta ); 1081 #else1082 alpha = Clip3( 0.05, 20.0, alpha );1083 beta = Clip3( -3.0, -0.1, beta );1084 #endif1085 936 TRCParameter rcPara; 1086 937 rcPara.m_alpha = alpha; … … 1090 941 } 1091 942 1092 #if !M0036_RC_IMPROVEMENT1093 Double TEncRCPic::getEffectivePercentage()1094 {1095 Int effectivePiexels = 0;1096 Int totalPixels = 0;1097 1098 for ( Int i=0; i<m_numberOfLCU; i++ )1099 {1100 totalPixels += m_LCUs[i].m_numberOfPixel;1101 if ( m_LCUs[i].m_QP > 0 )1102 {1103 effectivePiexels += m_LCUs[i].m_numberOfPixel;1104 }1105 }1106 1107 Double effectivePixelPercentage = (Double)effectivePiexels/(Double)totalPixels;1108 return effectivePixelPercentage;1109 }1110 #endif1111 1112 943 Double TEncRCPic::calAverageQP() 1113 944 { … … 1164 995 } 1165 996 1166 #if M0036_RC_IMPROVEMENT1167 #if RATE_CONTROL_INTRA1168 997 Void TEncRCPic::updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda, SliceType eSliceType) 1169 #else1170 Void TEncRCPic::updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda )1171 #endif1172 #else1173 Void TEncRCPic::updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda, Double effectivePercentage )1174 #endif1175 998 { 1176 999 m_picActualHeaderBits = actualHeaderBits; … … 1185 1008 } 1186 1009 m_picLambda = averageLambda; 1187 #if !M0036_RC_IMPROVEMENT1188 for ( Int i=0; i<m_numberOfLCU; i++ )1189 {1190 m_totalMAD += m_LCUs[i].m_MAD;1191 }1192 #endif1193 1010 1194 1011 Double alpha = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha; 1195 1012 Double beta = m_encRCSeq->getPicPara( m_frameLevel ).m_beta; 1196 #if RATE_CONTROL_INTRA1197 1013 if (eSliceType == I_SLICE) 1198 1014 { … … 1201 1017 else 1202 1018 { 1203 #endif1204 1019 // update parameters 1205 1020 Double picActualBits = ( Double )m_picActualBits; … … 1208 1023 Double inputLambda = m_picLambda; 1209 1024 1210 #if M0036_RC_IMPROVEMENT1211 1025 if ( inputLambda < 0.01 || calLambda < 0.01 || picActualBpp < 0.0001 ) 1212 #else1213 if ( inputLambda < 0.01 || calLambda < 0.01 || picActualBpp < 0.0001 || effectivePercentage < 0.05 )1214 #endif1215 1026 { 1216 1027 alpha *= ( 1.0 - m_encRCSeq->getAlphaUpdate() / 2.0 ); 1217 1028 beta *= ( 1.0 - m_encRCSeq->getBetaUpdate() / 2.0 ); 1218 1029 1219 #if M0036_RC_IMPROVEMENT1220 1030 alpha = Clip3( g_RCAlphaMinValue, g_RCAlphaMaxValue, alpha ); 1221 1031 beta = Clip3( g_RCBetaMinValue, g_RCBetaMaxValue, beta ); 1222 #else1223 alpha = Clip3( 0.05, 20.0, alpha );1224 beta = Clip3( -3.0, -0.1, beta );1225 #endif1226 1032 TRCParameter rcPara; 1227 1033 rcPara.m_alpha = alpha; … … 1235 1041 alpha += m_encRCSeq->getAlphaUpdate() * ( log( inputLambda ) - log( calLambda ) ) * alpha; 1236 1042 double lnbpp = log( picActualBpp ); 1237 #if M0036_RC_IMPROVEMENT1238 1043 lnbpp = Clip3( -5.0, -0.1, lnbpp ); 1239 #else1240 lnbpp = Clip3( -5.0, 1.0, lnbpp );1241 #endif1242 1044 beta += m_encRCSeq->getBetaUpdate() * ( log( inputLambda ) - log( calLambda ) ) * lnbpp; 1243 1045 1244 #if M0036_RC_IMPROVEMENT1245 1046 alpha = Clip3( g_RCAlphaMinValue, g_RCAlphaMaxValue, alpha ); 1246 1047 beta = Clip3( g_RCBetaMinValue, g_RCBetaMaxValue, beta ); 1247 #else 1248 alpha = Clip3( 0.05, 20.0, alpha ); 1249 beta = Clip3( -3.0, -0.1, beta ); 1250 #endif 1251 #if RATE_CONTROL_INTRA 1252 } 1253 #endif 1048 } 1254 1049 1255 1050 TRCParameter rcPara; … … 1259 1054 m_encRCSeq->setPicPara( m_frameLevel, rcPara ); 1260 1055 1261 #if M0036_RC_IMPROVEMENT1262 1056 if ( m_frameLevel == 1 ) 1263 1057 { … … 1266 1060 m_encRCSeq->setLastLambda( updateLastLambda ); 1267 1061 } 1268 #endif 1269 } 1270 1271 #if RATE_CONTROL_INTRA 1062 } 1063 1272 1064 Int TEncRCPic::getRefineBitsForIntra( Int orgBits ) 1273 1065 { … … 1358 1150 return estLambda; 1359 1151 } 1360 #endif1361 1152 1362 1153 TEncRateCtrl::TEncRateCtrl() … … 1392 1183 } 1393 1184 1394 #if M0036_RC_IMPROVEMENT1395 1185 Void TEncRateCtrl::init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP] ) 1396 #else1397 Void TEncRateCtrl::init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Bool keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP] )1398 #endif1399 1186 { 1400 1187 destroy(); … … 1411 1198 1412 1199 Int numberOfLevel = 1; 1413 #if M0036_RC_IMPROVEMENT1414 1200 Int adaptiveBit = 0; 1415 1201 if ( keepHierBits > 0 ) 1416 #else1417 if ( keepHierBits )1418 #endif1419 1202 { 1420 1203 numberOfLevel = Int( log((Double)GOPSize)/log(2.0) + 0.5 ) + 1; … … 1439 1222 } 1440 1223 1441 #if M0036_RC_IMPROVEMENT1442 1224 if ( keepHierBits > 0 ) 1443 #else1444 if ( keepHierBits )1445 #endif1446 1225 { 1447 1226 Double bpp = (Double)( targetBitrate / (Double)( frameRate*picWidth*picHeight ) ); … … 1476 1255 bitsRatio[3] = 14; 1477 1256 } 1478 #if M0036_RC_IMPROVEMENT1479 1257 if ( keepHierBits == 2 ) 1480 1258 { 1481 1259 adaptiveBit = 1; 1482 1260 } 1483 #endif1484 1261 } 1485 1262 else if ( GOPSize == 8 && !isLowdelay ) … … 1529 1306 bitsRatio[7] = 1; 1530 1307 } 1531 #if M0036_RC_IMPROVEMENT1532 1308 if ( keepHierBits == 2 ) 1533 1309 { 1534 1310 adaptiveBit = 2; 1535 1311 } 1536 #endif1537 1312 } 1538 1313 else 1539 1314 { 1540 #if M0036_RC_IMPROVEMENT1541 1315 printf( "\n hierarchical bit allocation is not support for the specified coding structure currently.\n" ); 1542 #else1543 printf( "\n hierarchical bit allocation is not support for the specified coding structure currently." );1544 #endif1545 1316 } 1546 1317 } … … 1555 1326 } 1556 1327 } 1557 #if M0036_RC_IMPROVEMENT1558 1328 if ( keepHierBits > 0 ) 1559 #else1560 if ( keepHierBits )1561 #endif1562 1329 { 1563 1330 if ( GOPSize == 4 && isLowdelay ) … … 1594 1361 1595 1362 m_encRCSeq = new TEncRCSeq; 1596 #if M0036_RC_IMPROVEMENT1597 1363 m_encRCSeq->create( totalFrames, targetBitrate, frameRate, GOPSize, picWidth, picHeight, LCUWidth, LCUHeight, numberOfLevel, useLCUSeparateModel, adaptiveBit ); 1598 #else1599 m_encRCSeq->create( totalFrames, targetBitrate, frameRate, GOPSize, picWidth, picHeight, LCUWidth, LCUHeight, numberOfLevel, useLCUSeparateModel );1600 #endif1601 1364 m_encRCSeq->initBitsRatio( bitsRatio ); 1602 1365 m_encRCSeq->initGOPID2Level( GOPID2Level ); … … 1629 1392 } 1630 1393 1631 #else1632 1633 #define ADJUSTMENT_FACTOR 0.601634 #define HIGH_QSTEP_THRESHOLD 9.52381635 #define HIGH_QSTEP_ALPHA 4.93711636 #define HIGH_QSTEP_BETA 0.09221637 #define LOW_QSTEP_ALPHA 16.74291638 #define LOW_QSTEP_BETA -1.14941639 1640 #define MAD_PRED_Y1 1.01641 #define MAD_PRED_Y2 0.01642 1643 enum MAD_HISOTRY {1644 MAD_PPPrevious = 0,1645 MAD_PPrevious = 1,1646 MAD_Previous = 21647 };1648 1649 Void MADLinearModel::initMADLinearModel()1650 {1651 m_activeOn = false;1652 m_paramY1 = 1.0;1653 m_paramY2 = 0.0;1654 m_costMADs[0] = m_costMADs[1] = m_costMADs[2] = 0.0;1655 }1656 1657 Double MADLinearModel::getMAD()1658 {1659 Double costPredMAD = m_paramY1 * m_costMADs[MAD_Previous] + m_paramY2;1660 1661 if(costPredMAD < 0)1662 {1663 costPredMAD = m_costMADs[MAD_Previous];1664 m_paramY1 = MAD_PRED_Y1;1665 m_paramY2 = MAD_PRED_Y2;1666 }1667 return costPredMAD;1668 }1669 1670 Void MADLinearModel::updateMADLiearModel()1671 {1672 Double dNewY1 = ((m_costMADs[MAD_Previous] - m_costMADs[MAD_PPrevious]) / (m_costMADs[MAD_PPrevious] - m_costMADs[MAD_PPPrevious]));1673 Double dNewY2 = (m_costMADs[MAD_Previous] - (dNewY1*m_costMADs[MAD_PPrevious]));1674 1675 m_paramY1 = 0.70+0.20*m_paramY1+ 0.10*dNewY1;1676 m_paramY2 = 0.20*m_paramY2+ 0.10*dNewY2;1677 }1678 1679 Void MADLinearModel::updateMADHistory(Double dMAD)1680 {1681 m_costMADs[MAD_PPPrevious] = m_costMADs[MAD_PPrevious];1682 m_costMADs[MAD_PPrevious ] = m_costMADs[MAD_Previous ];1683 m_costMADs[MAD_Previous ] = dMAD;1684 m_activeOn = (m_costMADs[MAD_Previous ] && m_costMADs[MAD_PPrevious ] && m_costMADs[MAD_PPPrevious]);1685 }1686 1687 1688 Void PixelBaseURQQuadraticModel::initPixelBaseQuadraticModel()1689 {1690 m_paramHighX1 = HIGH_QSTEP_ALPHA;1691 m_paramHighX2 = HIGH_QSTEP_BETA;1692 m_paramLowX1 = LOW_QSTEP_ALPHA;1693 m_paramLowX2 = LOW_QSTEP_BETA;1694 }1695 1696 Int PixelBaseURQQuadraticModel::getQP(Int qp, Int targetBits, Int numberOfPixels, Double costPredMAD)1697 {1698 Double qStep;1699 Double bppPerMAD = (Double)(targetBits/(numberOfPixels*costPredMAD));1700 1701 if(xConvertQP2QStep(qp) >= HIGH_QSTEP_THRESHOLD)1702 {1703 qStep = 1/( sqrt((bppPerMAD/m_paramHighX1)+((m_paramHighX2*m_paramHighX2)/(4*m_paramHighX1*m_paramHighX1))) - (m_paramHighX2/(2*m_paramHighX1)));1704 }1705 else1706 {1707 qStep = 1/( sqrt((bppPerMAD/m_paramLowX1)+((m_paramLowX2*m_paramLowX2)/(4*m_paramLowX1*m_paramLowX1))) - (m_paramLowX2/(2*m_paramLowX1)));1708 }1709 1710 return xConvertQStep2QP(qStep);1711 }1712 1713 Void PixelBaseURQQuadraticModel::updatePixelBasedURQQuadraticModel (Int qp, Int bits, Int numberOfPixels, Double costMAD)1714 {1715 Double qStep = xConvertQP2QStep(qp);1716 Double invqStep = (1/qStep);1717 Double paramNewX1, paramNewX2;1718 1719 if(qStep >= HIGH_QSTEP_THRESHOLD)1720 {1721 paramNewX2 = (((bits/(numberOfPixels*costMAD))-(23.3772*invqStep*invqStep))/((1-200*invqStep)*invqStep));1722 paramNewX1 = (23.3772-200*paramNewX2);1723 m_paramHighX1 = 0.70*HIGH_QSTEP_ALPHA + 0.20 * m_paramHighX1 + 0.10 * paramNewX1;1724 m_paramHighX2 = 0.70*HIGH_QSTEP_BETA + 0.20 * m_paramHighX2 + 0.10 * paramNewX2;1725 }1726 else1727 {1728 paramNewX2 = (((bits/(numberOfPixels*costMAD))-(5.8091*invqStep*invqStep))/((1-9.5455*invqStep)*invqStep));1729 paramNewX1 = (5.8091-9.5455*paramNewX2);1730 m_paramLowX1 = 0.90*LOW_QSTEP_ALPHA + 0.09 * m_paramLowX1 + 0.01 * paramNewX1;1731 m_paramLowX2 = 0.90*LOW_QSTEP_BETA + 0.09 * m_paramLowX2 + 0.01 * paramNewX2;1732 }1733 }1734 1735 Bool PixelBaseURQQuadraticModel::checkUpdateAvailable(Int qpReference )1736 {1737 Double qStep = xConvertQP2QStep(qpReference);1738 1739 if (qStep > xConvertQP2QStep(MAX_QP)1740 ||qStep < xConvertQP2QStep(MIN_QP) )1741 {1742 return false;1743 }1744 1745 return true;1746 }1747 1748 Double PixelBaseURQQuadraticModel::xConvertQP2QStep(Int qp )1749 {1750 Int i;1751 Double qStep;1752 static const Double mapQP2QSTEP[6] = { 0.625, 0.703, 0.797, 0.891, 1.000, 1.125 };1753 1754 qStep = mapQP2QSTEP[qp % 6];1755 for( i=0; i<(qp/6); i++)1756 {1757 qStep *= 2;1758 }1759 1760 return qStep;1761 }1762 1763 Int PixelBaseURQQuadraticModel::xConvertQStep2QP(Double qStep )1764 {1765 Int per = 0, rem = 0;1766 1767 if( qStep < xConvertQP2QStep(MIN_QP))1768 {1769 return MIN_QP;1770 }1771 else if (qStep > xConvertQP2QStep(MAX_QP) )1772 {1773 return MAX_QP;1774 }1775 1776 while( qStep > xConvertQP2QStep(5) )1777 {1778 qStep /= 2.0;1779 per++;1780 }1781 1782 if (qStep <= 0.625)1783 {1784 rem = 0;1785 }1786 else if (qStep <= 0.703)1787 {1788 rem = 1;1789 }1790 else if (qStep <= 0.797)1791 {1792 rem = 2;1793 }1794 else if (qStep <= 0.891)1795 {1796 rem = 3;1797 }1798 else if (qStep <= 1.000)1799 {1800 rem = 4;1801 }1802 else1803 {1804 rem = 5;1805 }1806 return (per * 6 + rem);1807 }1808 1809 1810 Void TEncRateCtrl::create(Int sizeIntraPeriod, Int sizeGOP, Int frameRate, Int targetKbps, Int qp, Int numLCUInBasicUnit, Int sourceWidth, Int sourceHeight, Int maxCUWidth, Int maxCUHeight)1811 {1812 Int leftInHeight, leftInWidth;1813 1814 m_sourceWidthInLCU = (sourceWidth / maxCUWidth ) + (( sourceWidth % maxCUWidth ) ? 1 : 0);1815 m_sourceHeightInLCU = (sourceHeight / maxCUHeight) + (( sourceHeight % maxCUHeight) ? 1 : 0);1816 m_isLowdelay = (sizeIntraPeriod == -1) ? true : false;1817 m_prevBitrate = ( targetKbps << 10 ); // in units of 1,024 bps1818 m_currBitrate = ( targetKbps << 10 );1819 m_frameRate = frameRate;1820 m_refFrameNum = m_isLowdelay ? (sizeGOP) : (sizeGOP>>1);1821 m_nonRefFrameNum = sizeGOP-m_refFrameNum;1822 m_sizeGOP = sizeGOP;1823 m_numOfPixels = ((sourceWidth*sourceHeight*3)>>1);1824 m_indexGOP = 0;1825 m_indexFrame = 0;1826 m_indexLCU = 0;1827 m_indexUnit = 0;1828 m_indexRefFrame = 0;1829 m_indexNonRefFrame = 0;1830 m_occupancyVB = 0;1831 m_initialOVB = 0;1832 m_targetBufLevel = 0;1833 m_initialTBL = 0;1834 m_occupancyVBInFrame = 0;1835 m_remainingBitsInGOP = (m_currBitrate*sizeGOP/m_frameRate);1836 m_remainingBitsInFrame = 0;1837 m_numUnitInFrame = m_sourceWidthInLCU*m_sourceHeightInLCU;1838 m_cMADLinearModel. initMADLinearModel();1839 m_cPixelURQQuadraticModel.initPixelBaseQuadraticModel();1840 1841 m_costRefAvgWeighting = 0.0;1842 m_costNonRefAvgWeighting = 0.0;1843 m_costAvgbpp = 0.0;1844 m_activeUnitLevelOn = false;1845 1846 m_pcFrameData = new FrameData [sizeGOP+1]; initFrameData(qp);1847 m_pcLCUData = new LCUData [m_numUnitInFrame]; initUnitData (qp);1848 1849 for(Int i = 0, addressUnit = 0; i < m_sourceHeightInLCU*maxCUHeight; i += maxCUHeight)1850 {1851 leftInHeight = sourceHeight - i;1852 leftInHeight = min(leftInHeight, maxCUHeight);1853 for(Int j = 0; j < m_sourceWidthInLCU*maxCUWidth; j += maxCUWidth, addressUnit++)1854 {1855 leftInWidth = sourceWidth - j;1856 leftInWidth = min(leftInWidth, maxCUWidth);1857 m_pcLCUData[addressUnit].m_widthInPixel = leftInWidth;1858 m_pcLCUData[addressUnit].m_heightInPixel= leftInHeight;1859 m_pcLCUData[addressUnit].m_pixels = ((leftInHeight*leftInWidth*3)>>1);1860 }1861 }1862 }1863 1864 Void TEncRateCtrl::destroy()1865 {1866 if(m_pcFrameData)1867 {1868 delete [] m_pcFrameData;1869 m_pcFrameData = NULL;1870 }1871 if(m_pcLCUData)1872 {1873 delete [] m_pcLCUData;1874 m_pcLCUData = NULL;1875 }1876 }1877 1878 Void TEncRateCtrl::initFrameData (Int qp)1879 {1880 for(Int i = 0 ; i <= m_sizeGOP; i++)1881 {1882 m_pcFrameData[i].m_isReferenced = false;1883 m_pcFrameData[i].m_costMAD = 0.0;1884 m_pcFrameData[i].m_bits = 0;1885 m_pcFrameData[i].m_qp = qp;1886 }1887 }1888 1889 Void TEncRateCtrl::initUnitData (Int qp)1890 {1891 for(Int i = 1 ; i < m_numUnitInFrame; i++)1892 {1893 m_pcLCUData[i].m_qp = qp;1894 m_pcLCUData[i].m_bits = 0;1895 m_pcLCUData[i].m_pixels = 0;1896 m_pcLCUData[i].m_widthInPixel = 0;1897 m_pcLCUData[i].m_heightInPixel = 0;1898 m_pcLCUData[i].m_costMAD = 0.0;1899 }1900 }1901 1902 Int TEncRateCtrl::getFrameQP(Bool isReferenced, Int POC)1903 {1904 Int numofReferenced = 0;1905 Int finalQP = 0;1906 FrameData* pcFrameData;1907 1908 m_indexPOCInGOP = (POC%m_sizeGOP) == 0 ? m_sizeGOP : (POC%m_sizeGOP);1909 pcFrameData = &m_pcFrameData[m_indexPOCInGOP];1910 1911 if(m_indexFrame != 0)1912 {1913 if(isReferenced)1914 {1915 Double gamma = m_isLowdelay ? 0.5 : 0.25;1916 Double beta = m_isLowdelay ? 0.9 : 0.6;1917 Int numRemainingRefFrames = m_refFrameNum - m_indexRefFrame;1918 Int numRemainingNRefFrames = m_nonRefFrameNum - m_indexNonRefFrame;1919 1920 Double targetBitsOccupancy = (m_currBitrate/(Double)m_frameRate) + gamma*(m_targetBufLevel-m_occupancyVB - (m_initialOVB/(Double)m_frameRate));1921 Double targetBitsLeftBudget = ((m_costRefAvgWeighting*m_remainingBitsInGOP)/((m_costRefAvgWeighting*numRemainingRefFrames)+(m_costNonRefAvgWeighting*numRemainingNRefFrames)));1922 1923 m_targetBits = (Int)(beta * targetBitsLeftBudget + (1-beta) * targetBitsOccupancy);1924 1925 if(m_targetBits <= 0 || m_remainingBitsInGOP <= 0)1926 {1927 finalQP = m_pcFrameData[m_indexPrevPOCInGOP].m_qp + 2;1928 }1929 else1930 {1931 Double costPredMAD = m_cMADLinearModel.getMAD();1932 Int qpLowerBound = m_pcFrameData[m_indexPrevPOCInGOP].m_qp-2;1933 Int qpUpperBound = m_pcFrameData[m_indexPrevPOCInGOP].m_qp+2;1934 finalQP = m_cPixelURQQuadraticModel.getQP(m_pcFrameData[m_indexPrevPOCInGOP].m_qp, m_targetBits, m_numOfPixels, costPredMAD);1935 finalQP = max(qpLowerBound, min(qpUpperBound, finalQP));1936 m_activeUnitLevelOn = true;1937 m_remainingBitsInFrame = m_targetBits;1938 m_costAvgbpp = (m_targetBits/(Double)m_numOfPixels);1939 }1940 1941 m_indexRefFrame++;1942 }1943 else1944 {1945 Int bwdQP = m_pcFrameData[m_indexPOCInGOP-1].m_qp;1946 Int fwdQP = m_pcFrameData[m_indexPOCInGOP+1].m_qp;1947 1948 if( (fwdQP+bwdQP) == m_pcFrameData[m_indexPOCInGOP-1].m_qp1949 ||(fwdQP+bwdQP) == m_pcFrameData[m_indexPOCInGOP+1].m_qp)1950 {1951 finalQP = (fwdQP+bwdQP);1952 }1953 else if(bwdQP != fwdQP)1954 {1955 finalQP = ((bwdQP+fwdQP+2)>>1);1956 }1957 else1958 {1959 finalQP = bwdQP+2;1960 }1961 m_indexNonRefFrame++;1962 }1963 }1964 else1965 {1966 Int lastQPminus2 = m_pcFrameData[0].m_qp - 2;1967 Int lastQPplus2 = m_pcFrameData[0].m_qp + 2;1968 1969 for(Int idx = 1; idx <= m_sizeGOP; idx++)1970 {1971 if(m_pcFrameData[idx].m_isReferenced)1972 {1973 finalQP += m_pcFrameData[idx].m_qp;1974 numofReferenced++;1975 }1976 }1977 1978 finalQP = (numofReferenced == 0) ? m_pcFrameData[0].m_qp : ((finalQP + (1<<(numofReferenced>>1)))/numofReferenced);1979 finalQP = max( lastQPminus2, min( lastQPplus2, finalQP));1980 1981 Double costAvgFrameBits = m_remainingBitsInGOP/(Double)m_sizeGOP;1982 Int bufLevel = m_occupancyVB + m_initialOVB;1983 1984 if(abs(bufLevel) > costAvgFrameBits)1985 {1986 if(bufLevel < 0)1987 {1988 finalQP -= 2;1989 }1990 else1991 {1992 finalQP += 2;1993 }1994 }1995 m_indexRefFrame++;1996 }1997 finalQP = max(MIN_QP, min(MAX_QP, finalQP));1998 1999 for(Int indexLCU = 0 ; indexLCU < m_numUnitInFrame; indexLCU++)2000 {2001 m_pcLCUData[indexLCU].m_qp = finalQP;2002 }2003 2004 pcFrameData->m_isReferenced = isReferenced;2005 pcFrameData->m_qp = finalQP;2006 2007 return finalQP;2008 }2009 2010 Bool TEncRateCtrl::calculateUnitQP ()2011 {2012 if(!m_activeUnitLevelOn || m_indexLCU == 0)2013 {2014 return false;2015 }2016 Int upperQPBound, lowerQPBound, finalQP;2017 Int colQP = m_pcLCUData[m_indexLCU].m_qp;2018 Double colMAD = m_pcLCUData[m_indexLCU].m_costMAD;2019 Double budgetInUnit = m_pcLCUData[m_indexLCU].m_pixels*m_costAvgbpp;2020 2021 2022 Int targetBitsOccupancy = (Int)(budgetInUnit - (m_occupancyVBInFrame/(m_numUnitInFrame-m_indexUnit)));2023 Int targetBitsLeftBudget= (Int)((m_remainingBitsInFrame*m_pcLCUData[m_indexLCU].m_pixels)/(Double)(m_numOfPixels-m_codedPixels));2024 Int targetBits = (targetBitsLeftBudget>>1) + (targetBitsOccupancy>>1);2025 2026 2027 if( m_indexLCU >= m_sourceWidthInLCU)2028 {2029 upperQPBound = ( (m_pcLCUData[m_indexLCU-1].m_qp + m_pcLCUData[m_indexLCU - m_sourceWidthInLCU].m_qp)>>1) + MAX_DELTA_QP;2030 lowerQPBound = ( (m_pcLCUData[m_indexLCU-1].m_qp + m_pcLCUData[m_indexLCU - m_sourceWidthInLCU].m_qp)>>1) - MAX_DELTA_QP;2031 }2032 else2033 {2034 upperQPBound = m_pcLCUData[m_indexLCU-1].m_qp + MAX_DELTA_QP;2035 lowerQPBound = m_pcLCUData[m_indexLCU-1].m_qp - MAX_DELTA_QP;2036 }2037 2038 if(targetBits < 0)2039 {2040 finalQP = m_pcLCUData[m_indexLCU-1].m_qp + 1;2041 }2042 else2043 {2044 finalQP = m_cPixelURQQuadraticModel.getQP(colQP, targetBits, m_pcLCUData[m_indexLCU].m_pixels, colMAD);2045 }2046 2047 finalQP = max(lowerQPBound, min(upperQPBound, finalQP));2048 m_pcLCUData[m_indexLCU].m_qp = max(MIN_QP, min(MAX_QP, finalQP));2049 2050 return true;2051 }2052 2053 Void TEncRateCtrl::updateRCGOPStatus()2054 {2055 m_remainingBitsInGOP = ((m_currBitrate/m_frameRate)*m_sizeGOP) - m_occupancyVB;2056 2057 FrameData cFrameData = m_pcFrameData[m_sizeGOP];2058 initFrameData();2059 2060 m_pcFrameData[0] = cFrameData;2061 m_indexGOP++;2062 m_indexFrame = 0;2063 m_indexRefFrame = 0;2064 m_indexNonRefFrame = 0;2065 }2066 2067 Void TEncRateCtrl::updataRCFrameStatus(Int frameBits, SliceType eSliceType)2068 {2069 FrameData* pcFrameData = &m_pcFrameData[m_indexPOCInGOP];2070 Int occupancyBits;2071 Double adjustmentBits;2072 2073 m_remainingBitsInGOP = m_remainingBitsInGOP + ( ((m_currBitrate-m_prevBitrate)/m_frameRate)*(m_sizeGOP-m_indexFrame) ) - frameBits;2074 occupancyBits = (Int)((Double)frameBits - (m_currBitrate/(Double)m_frameRate));2075 2076 if( (occupancyBits < 0) && (m_initialOVB > 0) )2077 {2078 adjustmentBits = xAdjustmentBits(occupancyBits, m_initialOVB );2079 2080 if(m_initialOVB < 0)2081 {2082 adjustmentBits = m_initialOVB;2083 occupancyBits += (Int)adjustmentBits;2084 m_initialOVB = 0;2085 }2086 }2087 else if( (occupancyBits > 0) && (m_initialOVB < 0) )2088 {2089 adjustmentBits = xAdjustmentBits(m_initialOVB, occupancyBits );2090 2091 if(occupancyBits < 0)2092 {2093 adjustmentBits = occupancyBits;2094 m_initialOVB += (Int)adjustmentBits;2095 occupancyBits = 0;2096 }2097 }2098 2099 if(m_indexGOP == 0)2100 {2101 m_initialOVB = occupancyBits;2102 }2103 else2104 {2105 m_occupancyVB= m_occupancyVB + occupancyBits;2106 }2107 2108 if(pcFrameData->m_isReferenced)2109 {2110 m_costRefAvgWeighting = ((pcFrameData->m_bits*pcFrameData->m_qp)/8.0) + (7.0*(m_costRefAvgWeighting)/8.0);2111 2112 if(m_indexFrame == 0)2113 {2114 m_initialTBL = m_targetBufLevel = (frameBits - (m_currBitrate/m_frameRate));2115 }2116 else2117 {2118 Int distance = (m_costNonRefAvgWeighting == 0) ? 0 : 1;2119 m_targetBufLevel = m_targetBufLevel2120 - (m_initialTBL/(m_refFrameNum-1))2121 + (Int)((m_costRefAvgWeighting*(distance+1)*m_currBitrate)/(m_frameRate*(m_costRefAvgWeighting+(m_costNonRefAvgWeighting*distance))))2122 - (m_currBitrate/m_frameRate);2123 }2124 2125 if(m_cMADLinearModel.IsUpdateAvailable())2126 {2127 m_cMADLinearModel.updateMADLiearModel();2128 }2129 2130 if(eSliceType != I_SLICE &&2131 m_cPixelURQQuadraticModel.checkUpdateAvailable(pcFrameData->m_qp))2132 {2133 m_cPixelURQQuadraticModel.updatePixelBasedURQQuadraticModel(pcFrameData->m_qp, pcFrameData->m_bits, m_numOfPixels, pcFrameData->m_costMAD);2134 }2135 }2136 else2137 {2138 m_costNonRefAvgWeighting = ((pcFrameData->m_bits*pcFrameData->m_qp)/8.0) + (7.0*(m_costNonRefAvgWeighting)/8.0);2139 }2140 2141 m_indexFrame++;2142 m_indexLCU = 0;2143 m_indexUnit = 0;2144 m_occupancyVBInFrame = 0;2145 m_remainingBitsInFrame = 0;2146 m_codedPixels = 0;2147 m_activeUnitLevelOn = false;2148 m_costAvgbpp = 0.0;2149 }2150 Void TEncRateCtrl::updataRCUnitStatus ()2151 {2152 if(!m_activeUnitLevelOn || m_indexLCU == 0)2153 {2154 return;2155 }2156 2157 m_codedPixels += m_pcLCUData[m_indexLCU-1].m_pixels;2158 m_remainingBitsInFrame = m_remainingBitsInFrame - m_pcLCUData[m_indexLCU-1].m_bits;2159 m_occupancyVBInFrame = (Int)(m_occupancyVBInFrame + m_pcLCUData[m_indexLCU-1].m_bits - m_pcLCUData[m_indexLCU-1].m_pixels*m_costAvgbpp);2160 2161 if( m_cPixelURQQuadraticModel.checkUpdateAvailable(m_pcLCUData[m_indexLCU-1].m_qp) )2162 {2163 m_cPixelURQQuadraticModel.updatePixelBasedURQQuadraticModel(m_pcLCUData[m_indexLCU-1].m_qp, m_pcLCUData[m_indexLCU-1].m_bits, m_pcLCUData[m_indexLCU-1].m_pixels, m_pcLCUData[m_indexLCU-1].m_costMAD);2164 }2165 2166 m_indexUnit++;2167 }2168 2169 Void TEncRateCtrl::updateFrameData(UInt64 actualFrameBits)2170 {2171 Double costMAD = 0.0;2172 2173 for(Int i = 0; i < m_numUnitInFrame; i++)2174 {2175 costMAD += m_pcLCUData[i].m_costMAD;2176 }2177 2178 m_pcFrameData[m_indexPOCInGOP].m_costMAD = (costMAD/(Double)m_numUnitInFrame);2179 m_pcFrameData[m_indexPOCInGOP].m_bits = (Int)actualFrameBits;2180 2181 if(m_pcFrameData[m_indexPOCInGOP].m_isReferenced)2182 {2183 m_indexPrevPOCInGOP = m_indexPOCInGOP;2184 m_cMADLinearModel.updateMADHistory(m_pcFrameData[m_indexPOCInGOP].m_costMAD);2185 }2186 }2187 2188 Void TEncRateCtrl::updateLCUData(TComDataCU* pcCU, UInt64 actualLCUBits, Int qp)2189 {2190 Int x, y;2191 Double costMAD = 0.0;2192 2193 Pel* pOrg = pcCU->getPic()->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0);2194 Pel* pRec = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), 0);2195 Int stride = pcCU->getPic()->getStride();2196 2197 Int width = m_pcLCUData[m_indexLCU].m_widthInPixel;2198 Int height = m_pcLCUData[m_indexLCU].m_heightInPixel;2199 2200 for( y = 0; y < height; y++ )2201 {2202 for( x = 0; x < width; x++ )2203 {2204 costMAD += abs( pOrg[x] - pRec[x] );2205 }2206 pOrg += stride;2207 pRec += stride;2208 }2209 m_pcLCUData[m_indexLCU ].m_qp = qp;2210 m_pcLCUData[m_indexLCU ].m_costMAD = (costMAD /(Double)(width*height));2211 m_pcLCUData[m_indexLCU++].m_bits = (Int)actualLCUBits;2212 }2213 2214 Double TEncRateCtrl::xAdjustmentBits(Int& reductionBits, Int& compensationBits)2215 {2216 Double adjustment = ADJUSTMENT_FACTOR*reductionBits;2217 reductionBits -= (Int)adjustment;2218 compensationBits += (Int)adjustment;2219 2220 return adjustment;2221 }2222 2223 #endif2224 -
trunk/source/Lib/TLibEncoder/TEncRateCtrl.h
r313 r540 55 55 //! \{ 56 56 57 #if RATE_CONTROL_LAMBDA_DOMAIN58 57 #include "../TLibEncoder/TEncCfg.h" 59 58 #include <list> … … 65 64 const Double g_RCWeightPicTargetBitInGOP = 0.9; 66 65 const Double g_RCWeightPicRargetBitInBuffer = 1.0 - g_RCWeightPicTargetBitInGOP; 67 #if M0036_RC_IMPROVEMENT68 66 const Int g_RCIterationNum = 20; 69 67 const Double g_RCWeightHistoryLambda = 0.5; … … 74 72 const Double g_RCBetaMinValue = -3.0; 75 73 const Double g_RCBetaMaxValue = -0.1; 76 #endif 77 78 #if RATE_CONTROL_INTRA 74 79 75 #define ALPHA 6.7542; 80 76 #define BETA1 1.2517 81 77 #define BETA2 1.7860 82 #endif83 78 84 79 struct TRCLCU … … 88 83 Int m_targetBits; 89 84 Double m_lambda; 90 #if M0036_RC_IMPROVEMENT91 85 Double m_bitWeight; 92 #else93 Double m_MAD;94 #endif95 86 Int m_numberOfPixel; 96 #if RATE_CONTROL_INTRA97 87 Double m_costIntra; 98 88 Int m_targetBitsLeft; 99 #endif100 89 }; 101 90 … … 113 102 114 103 public: 115 #if M0036_RC_IMPROVEMENT116 104 Void create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel, Int adaptiveBit ); 117 #else118 Void create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel );119 #endif120 105 Void destroy(); 121 106 Void initBitsRatio( Int bitsRatio[] ); … … 124 109 Void initLCUPara( TRCParameter** LCUPara = NULL ); // NULL to initial with default value 125 110 Void updateAfterPic ( Int bits ); 126 #if !RATE_CONTROL_INTRA127 Int getRefineBitsForIntra( Int orgBits );128 #endif129 #if M0036_RC_IMPROVEMENT130 111 Void setAllBitRatio( Double basicLambda, Double* equaCoeffA, Double* equaCoeffB ); 131 #endif132 112 133 113 public: … … 167 147 Double getBetaUpdate() { return m_betaUpdate; } 168 148 169 #if M0036_RC_IMPROVEMENT170 149 Int getAdaptiveBits() { return m_adaptiveBit; } 171 150 Double getLastLambda() { return m_lastLambda; } 172 151 Void setLastLambda( Double lamdba ) { m_lastLambda = lamdba; } 173 #endif174 152 175 153 private: … … 200 178 Bool m_useLCUSeparateModel; 201 179 202 #if M0036_RC_IMPROVEMENT203 180 Int m_adaptiveBit; 204 181 Double m_lastLambda; 205 #endif206 182 }; 207 183 … … 219 195 private: 220 196 Int xEstGOPTargetBits( TEncRCSeq* encRCSeq, Int GOPSize ); 221 #if M0036_RC_IMPROVEMENT222 197 Void xCalEquaCoeff( TEncRCSeq* encRCSeq, Double* lambdaRatio, Double* equaCoeffA, Double* equaCoeffB, Int GOPSize ); 223 198 Double xSolveEqua( Double targetBpp, Double* equaCoeffA, Double* equaCoeffB, Int GOPSize ); 224 #endif225 199 226 200 public: … … 251 225 Void destroy(); 252 226 253 #if !RATE_CONTROL_INTRA254 Double estimatePicLambda( list<TEncRCPic*>& listPreviousPictures );255 #endif256 227 Int estimatePicQP ( Double lambda, list<TEncRCPic*>& listPreviousPictures ); 257 #if RATE_CONTROL_INTRA258 228 Int getRefineBitsForIntra(Int orgBits); 259 229 Double calculateLambdaIntra(double alpha, double beta, double MADPerPixel, double bitsPerPixel); … … 264 234 Double getLCUTargetBpp(SliceType eSliceType); 265 235 Double getLCUEstLambdaAndQP(Double bpp, Int clipPicQP, Int *estQP); 266 #else267 Double getLCUTargetBpp();268 #endif269 236 Double getLCUEstLambda( Double bpp ); 270 237 Int getLCUEstQP( Double lambda, Int clipPicQP ); 271 238 272 239 Void updateAfterLCU( Int LCUIdx, Int bits, Int QP, Double lambda, Bool updateLCUParameter = true ); 273 #if M0036_RC_IMPROVEMENT274 #if RATE_CONTROL_INTRA275 240 Void updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda, SliceType eSliceType); 276 #else277 Void updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda );278 #endif279 #else280 Void updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda, Double effectivePercentage );281 #endif282 241 283 242 Void addToPictureLsit( list<TEncRCPic*>& listPreviousPictures ); 284 #if !M0036_RC_IMPROVEMENT285 Double getEffectivePercentage();286 #endif287 243 Double calAverageQP(); 288 244 Double calAverageLambda(); … … 300 256 Int getNumberOfLCU() { return m_numberOfLCU; } 301 257 Int getTargetBits() { return m_targetBits; } 302 #if !RATE_CONTROL_INTRA303 Void setTargetBits( Int bits ) { m_targetBits = bits; }304 #endif305 258 Int getEstHeaderBits() { return m_estHeaderBits; } 306 259 Int getLCULeft() { return m_LCULeft; } … … 312 265 TRCLCU& getLCU( Int LCUIdx ) { return m_LCUs[LCUIdx]; } 313 266 Int getPicActualHeaderBits() { return m_picActualHeaderBits; } 314 #if !M0036_RC_IMPROVEMENT315 Double getTotalMAD() { return m_totalMAD; }316 Void setTotalMAD( Double MAD ) { m_totalMAD = MAD; }317 #endif318 #if RATE_CONTROL_INTRA319 267 Void setTargetBits( Int bits ) { m_targetBits = bits; m_bitsLeft = bits;} 320 268 Void setTotalIntraCost(Double cost) { m_totalCostIntra = cost; } 321 269 Void getLCUInitTargetBits(); 322 #endif323 270 324 271 Int getPicActualBits() { return m_picActualBits; } … … 348 295 TRCLCU* m_LCUs; 349 296 Int m_picActualHeaderBits; // only SH and potential APS 350 #if !M0036_RC_IMPROVEMENT351 Double m_totalMAD;352 #endif353 #if RATE_CONTROL_INTRA354 297 Double m_totalCostIntra; 355 298 Double m_remainingCostIntra; 356 #endif357 299 Int m_picActualBits; // the whole picture, including header 358 300 Int m_picQP; // in integer form 359 301 Double m_picLambda; 360 #if !M0036_RC_IMPROVEMENT361 TEncRCPic* m_lastPicture;362 #endif363 302 }; 364 303 … … 370 309 371 310 public: 372 #if M0036_RC_IMPROVEMENT373 311 Void init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP] ); 374 #else375 Void init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Bool keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP] );376 #endif377 312 Void destroy(); 378 313 Void initRCPic( Int frameLevel ); … … 396 331 }; 397 332 398 #else399 400 // ====================================================================================================================401 // Class definition402 // ====================================================================================================================403 #define MAX_DELTA_QP 2404 #define MAX_CUDQP_DEPTH 0405 406 typedef struct FrameData407 {408 Bool m_isReferenced;409 Int m_qp;410 Int m_bits;411 Double m_costMAD;412 }FrameData;413 414 typedef struct LCUData415 {416 Int m_qp; ///< coded QP417 Int m_bits; ///< actually generated bits418 Int m_pixels; ///< number of pixels for a unit419 Int m_widthInPixel; ///< number of pixels for width420 Int m_heightInPixel; ///< number of pixels for height421 Double m_costMAD; ///< texture complexity for a unit422 }LCUData;423 424 class MADLinearModel425 {426 private:427 Bool m_activeOn;428 Double m_paramY1;429 Double m_paramY2;430 Double m_costMADs[3];431 432 public:433 MADLinearModel () {};434 ~MADLinearModel() {};435 436 Void initMADLinearModel ();437 Double getMAD ();438 Void updateMADLiearModel ();439 Void updateMADHistory (Double costMAD);440 Bool IsUpdateAvailable () { return m_activeOn; }441 };442 443 class PixelBaseURQQuadraticModel444 {445 private:446 Double m_paramHighX1;447 Double m_paramHighX2;448 Double m_paramLowX1;449 Double m_paramLowX2;450 public:451 PixelBaseURQQuadraticModel () {};452 ~PixelBaseURQQuadraticModel() {};453 454 Void initPixelBaseQuadraticModel ();455 Int getQP (Int qp, Int targetBits, Int numberOfPixels, Double costPredMAD);456 Void updatePixelBasedURQQuadraticModel (Int qp, Int bits, Int numberOfPixels, Double costMAD);457 Bool checkUpdateAvailable (Int qpReference );458 Double xConvertQP2QStep (Int qp );459 Int xConvertQStep2QP (Double qStep );460 };461 462 class TEncRateCtrl463 {464 private:465 Bool m_isLowdelay;466 Int m_prevBitrate;467 Int m_currBitrate;468 Int m_frameRate;469 Int m_refFrameNum;470 Int m_nonRefFrameNum;471 Int m_numOfPixels;472 Int m_sourceWidthInLCU;473 Int m_sourceHeightInLCU;474 Int m_sizeGOP;475 Int m_indexGOP;476 Int m_indexFrame;477 Int m_indexLCU;478 Int m_indexUnit;479 Int m_indexRefFrame;480 Int m_indexNonRefFrame;481 Int m_indexPOCInGOP;482 Int m_indexPrevPOCInGOP;483 Int m_occupancyVB;484 Int m_initialOVB;485 Int m_targetBufLevel;486 Int m_initialTBL;487 Int m_remainingBitsInGOP;488 Int m_remainingBitsInFrame;489 Int m_occupancyVBInFrame;490 Int m_targetBits;491 Int m_numUnitInFrame;492 Int m_codedPixels;493 Bool m_activeUnitLevelOn;494 Double m_costNonRefAvgWeighting;495 Double m_costRefAvgWeighting;496 Double m_costAvgbpp;497 498 FrameData* m_pcFrameData;499 LCUData* m_pcLCUData;500 501 MADLinearModel m_cMADLinearModel;502 PixelBaseURQQuadraticModel m_cPixelURQQuadraticModel;503 504 public:505 TEncRateCtrl () {};506 virtual ~TEncRateCtrl() {};507 508 Void create (Int sizeIntraPeriod, Int sizeGOP, Int frameRate, Int targetKbps, Int qp, Int numLCUInBasicUnit, Int sourceWidth, Int sourceHeight, Int maxCUWidth, Int maxCUHeight);509 Void destroy ();510 511 Void initFrameData (Int qp = 0);512 Void initUnitData (Int qp = 0);513 Int getFrameQP (Bool isReferenced, Int POC);514 Bool calculateUnitQP ();515 Int getUnitQP () { return m_pcLCUData[m_indexLCU].m_qp; }516 Void updateRCGOPStatus ();517 Void updataRCFrameStatus (Int frameBits, SliceType eSliceType);518 Void updataRCUnitStatus ();519 Void updateLCUData (TComDataCU* pcCU, UInt64 actualLCUBits, Int qp);520 Void updateFrameData (UInt64 actualFrameBits);521 Double xAdjustmentBits (Int& reductionBits, Int& compensationBits);522 Int getGOPId () { return m_indexFrame; }523 };524 333 #endif 525 334 526 #endif 527 528 335 -
trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp
r494 r540 45 45 //! \{ 46 46 47 48 #if HM_CLEANUP_SAO 49 50 /** rounding with IBDI 51 * \param x 52 */ 53 inline Double xRoundIbdi2(Int bitDepth, Double x) 54 { 55 return ((x)>0) ? (Int)(((Int)(x)+(1<<(bitDepth-8-1)))/(1<<(bitDepth-8))) : ((Int)(((Int)(x)-(1<<(bitDepth-8-1)))/(1<<(bitDepth-8)))); 56 } 57 58 inline Double xRoundIbdi(Int bitDepth, Double x) 59 { 60 return (bitDepth > 8 ? xRoundIbdi2(bitDepth, (x)) : ((x)>=0 ? ((Int)((x)+0.5)) : ((Int)((x)-0.5)))) ; 61 } 62 63 64 TEncSampleAdaptiveOffset::TEncSampleAdaptiveOffset() 65 { 66 m_pppcRDSbacCoder = NULL; 67 m_pcRDGoOnSbacCoder = NULL; 68 m_pppcBinCoderCABAC = NULL; 69 m_statData = NULL; 70 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 71 m_preDBFstatData = NULL; 72 #endif 73 } 74 75 TEncSampleAdaptiveOffset::~TEncSampleAdaptiveOffset() 76 { 77 destroyEncData(); 78 } 79 80 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 81 Void TEncSampleAdaptiveOffset::createEncData(Bool isPreDBFSamplesUsed) 82 #else 83 Void TEncSampleAdaptiveOffset::createEncData() 84 #endif 85 { 86 87 //cabac coder for RDO 88 m_pppcRDSbacCoder = new TEncSbac* [NUM_SAO_CABACSTATE_LABELS]; 89 m_pppcBinCoderCABAC = new TEncBinCABACCounter* [NUM_SAO_CABACSTATE_LABELS]; 90 91 for(Int cs=0; cs < NUM_SAO_CABACSTATE_LABELS; cs++) 92 { 93 m_pppcRDSbacCoder[cs] = new TEncSbac; 94 m_pppcBinCoderCABAC[cs] = new TEncBinCABACCounter; 95 m_pppcRDSbacCoder [cs]->init( m_pppcBinCoderCABAC [cs] ); 96 } 97 98 99 //statistics 100 m_statData = new SAOStatData**[m_numCTUsPic]; 101 for(Int i=0; i< m_numCTUsPic; i++) 102 { 103 m_statData[i] = new SAOStatData*[NUM_SAO_COMPONENTS]; 104 for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++) 105 { 106 m_statData[i][compIdx] = new SAOStatData[NUM_SAO_NEW_TYPES]; 107 } 108 } 109 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 110 if(isPreDBFSamplesUsed) 111 { 112 m_preDBFstatData = new SAOStatData**[m_numCTUsPic]; 113 for(Int i=0; i< m_numCTUsPic; i++) 114 { 115 m_preDBFstatData[i] = new SAOStatData*[NUM_SAO_COMPONENTS]; 116 for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++) 117 { 118 m_preDBFstatData[i][compIdx] = new SAOStatData[NUM_SAO_NEW_TYPES]; 119 } 120 } 121 122 } 123 #endif 124 125 #if SAO_ENCODING_CHOICE 126 ::memset(m_saoDisabledRate, 0, sizeof(m_saoDisabledRate)); 127 #endif 128 129 for(Int typeIdc=0; typeIdc < NUM_SAO_NEW_TYPES; typeIdc++) 130 { 131 m_skipLinesR[SAO_Y ][typeIdc]= 5; 132 m_skipLinesR[SAO_Cb][typeIdc]= m_skipLinesR[SAO_Cr][typeIdc]= 3; 133 134 m_skipLinesB[SAO_Y ][typeIdc]= 4; 135 m_skipLinesB[SAO_Cb][typeIdc]= m_skipLinesB[SAO_Cr][typeIdc]= 2; 136 137 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 138 if(isPreDBFSamplesUsed) 139 { 140 switch(typeIdc) 141 { 142 case SAO_TYPE_EO_0: 143 { 144 m_skipLinesR[SAO_Y ][typeIdc]= 5; 145 m_skipLinesR[SAO_Cb][typeIdc]= m_skipLinesR[SAO_Cr][typeIdc]= 3; 146 147 m_skipLinesB[SAO_Y ][typeIdc]= 3; 148 m_skipLinesB[SAO_Cb][typeIdc]= m_skipLinesB[SAO_Cr][typeIdc]= 1; 149 } 150 break; 151 case SAO_TYPE_EO_90: 152 { 153 m_skipLinesR[SAO_Y ][typeIdc]= 4; 154 m_skipLinesR[SAO_Cb][typeIdc]= m_skipLinesR[SAO_Cr][typeIdc]= 2; 155 156 m_skipLinesB[SAO_Y ][typeIdc]= 4; 157 m_skipLinesB[SAO_Cb][typeIdc]= m_skipLinesB[SAO_Cr][typeIdc]= 2; 158 } 159 break; 160 case SAO_TYPE_EO_135: 161 case SAO_TYPE_EO_45: 162 { 163 m_skipLinesR[SAO_Y ][typeIdc]= 5; 164 m_skipLinesR[SAO_Cb][typeIdc]= m_skipLinesR[SAO_Cr][typeIdc]= 3; 165 166 m_skipLinesB[SAO_Y ][typeIdc]= 4; 167 m_skipLinesB[SAO_Cb][typeIdc]= m_skipLinesB[SAO_Cr][typeIdc]= 2; 168 } 169 break; 170 case SAO_TYPE_BO: 171 { 172 m_skipLinesR[SAO_Y ][typeIdc]= 4; 173 m_skipLinesR[SAO_Cb][typeIdc]= m_skipLinesR[SAO_Cr][typeIdc]= 2; 174 175 m_skipLinesB[SAO_Y ][typeIdc]= 3; 176 m_skipLinesB[SAO_Cb][typeIdc]= m_skipLinesB[SAO_Cr][typeIdc]= 1; 177 } 178 break; 179 default: 180 { 181 printf("Not a supported type"); 182 assert(0); 183 exit(-1); 184 } 185 } 186 } 187 #endif 188 } 189 190 } 191 192 Void TEncSampleAdaptiveOffset::destroyEncData() 193 { 194 if(m_pppcRDSbacCoder != NULL) 195 { 196 for (Int cs = 0; cs < NUM_SAO_CABACSTATE_LABELS; cs ++ ) 197 { 198 delete m_pppcRDSbacCoder[cs]; 199 } 200 delete[] m_pppcRDSbacCoder; m_pppcRDSbacCoder = NULL; 201 } 202 203 if(m_pppcBinCoderCABAC != NULL) 204 { 205 for (Int cs = 0; cs < NUM_SAO_CABACSTATE_LABELS; cs ++ ) 206 { 207 delete m_pppcBinCoderCABAC[cs]; 208 } 209 delete[] m_pppcBinCoderCABAC; m_pppcBinCoderCABAC = NULL; 210 } 211 212 if(m_statData != NULL) 213 { 214 for(Int i=0; i< m_numCTUsPic; i++) 215 { 216 for(Int compIdx=0; compIdx< NUM_SAO_COMPONENTS; compIdx++) 217 { 218 delete[] m_statData[i][compIdx]; 219 } 220 delete[] m_statData[i]; 221 } 222 delete[] m_statData; m_statData = NULL; 223 } 224 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 225 if(m_preDBFstatData != NULL) 226 { 227 for(Int i=0; i< m_numCTUsPic; i++) 228 { 229 for(Int compIdx=0; compIdx< NUM_SAO_COMPONENTS; compIdx++) 230 { 231 delete[] m_preDBFstatData[i][compIdx]; 232 } 233 delete[] m_preDBFstatData[i]; 234 } 235 delete[] m_preDBFstatData; m_preDBFstatData = NULL; 236 } 237 238 #endif 239 } 240 241 Void TEncSampleAdaptiveOffset::initRDOCabacCoder(TEncSbac* pcRDGoOnSbacCoder, TComSlice* pcSlice) 242 { 243 m_pcRDGoOnSbacCoder = pcRDGoOnSbacCoder; 244 m_pcRDGoOnSbacCoder->setSlice(pcSlice); 245 m_pcRDGoOnSbacCoder->resetEntropy(); 246 m_pcRDGoOnSbacCoder->resetBits(); 247 248 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[SAO_CABACSTATE_PIC_INIT]); 249 } 250 251 252 253 Void TEncSampleAdaptiveOffset::SAOProcess(TComPic* pPic, Bool* sliceEnabled, const Double *lambdas 254 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 255 , Bool isPreDBFSamplesUsed 256 #endif 257 ) 258 { 259 TComPicYuv* orgYuv= pPic->getPicYuvOrg(); 260 TComPicYuv* resYuv= pPic->getPicYuvRec(); 261 m_labmda[SAO_Y]= lambdas[0]; m_labmda[SAO_Cb]= lambdas[1]; m_labmda[SAO_Cr]= lambdas[2]; 262 TComPicYuv* srcYuv = m_tempPicYuv; 263 resYuv->copyToPic(srcYuv); 264 srcYuv->setBorderExtension(false); 265 srcYuv->extendPicBorder(); 266 267 //collect statistics 268 getStatistics(m_statData, orgYuv, srcYuv, pPic); 269 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 270 if(isPreDBFSamplesUsed) 271 { 272 addPreDBFStatistics(m_statData); 273 } 274 #endif 275 //slice on/off 276 decidePicParams(sliceEnabled, pPic->getSlice(0)->getDepth()); 277 278 //block on/off 279 SAOBlkParam* reconParams = new SAOBlkParam[m_numCTUsPic]; //temporary parameter buffer for storing reconstructed SAO parameters 280 decideBlkParams(pPic, sliceEnabled, m_statData, srcYuv, resYuv, reconParams, pPic->getPicSym()->getSAOBlkParam()); 281 delete[] reconParams; 282 283 } 284 285 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 286 Void TEncSampleAdaptiveOffset::getPreDBFStatistics(TComPic* pPic) 287 { 288 getStatistics(m_preDBFstatData, pPic->getPicYuvOrg(), pPic->getPicYuvRec(), pPic, true); 289 } 290 291 Void TEncSampleAdaptiveOffset::addPreDBFStatistics(SAOStatData*** blkStats) 292 { 293 for(Int n=0; n< m_numCTUsPic; n++) 294 { 295 for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++) 296 { 297 for(Int typeIdc=0; typeIdc < NUM_SAO_NEW_TYPES; typeIdc++) 298 { 299 blkStats[n][compIdx][typeIdc] += m_preDBFstatData[n][compIdx][typeIdc]; 300 } 301 } 302 } 303 } 304 305 #endif 306 307 Void TEncSampleAdaptiveOffset::getStatistics(SAOStatData*** blkStats, TComPicYuv* orgYuv, TComPicYuv* srcYuv, TComPic* pPic 308 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 309 , Bool isCalculatePreDeblockSamples 310 #endif 311 ) 312 { 313 Bool isLeftAvail,isRightAvail,isAboveAvail,isBelowAvail,isAboveLeftAvail,isAboveRightAvail,isBelowLeftAvail,isBelowRightAvail; 314 315 for(Int ctu= 0; ctu < m_numCTUsPic; ctu++) 316 { 317 Int yPos = (ctu / m_numCTUInWidth)*m_maxCUHeight; 318 Int xPos = (ctu % m_numCTUInWidth)*m_maxCUWidth; 319 Int height = (yPos + m_maxCUHeight > m_picHeight)?(m_picHeight- yPos):m_maxCUHeight; 320 Int width = (xPos + m_maxCUWidth > m_picWidth )?(m_picWidth - xPos):m_maxCUWidth; 321 322 pPic->getPicSym()->deriveLoopFilterBoundaryAvailibility(ctu, isLeftAvail,isRightAvail,isAboveAvail,isBelowAvail,isAboveLeftAvail,isAboveRightAvail,isBelowLeftAvail,isBelowRightAvail); 323 324 //NOTE: The number of skipped lines during gathering CTU statistics depends on the slice boundary availabilities. 325 //For simplicity, here only picture boundaries are considered. 326 327 isRightAvail = (xPos + m_maxCUWidth < m_picWidth ); 328 isBelowAvail = (yPos + m_maxCUHeight < m_picHeight); 329 isBelowRightAvail = (isRightAvail && isBelowAvail); 330 isBelowLeftAvail = ((xPos > 0) && (isBelowAvail)); 331 isAboveRightAvail = ((yPos > 0) && (isRightAvail)); 332 333 for(Int compIdx=0; compIdx< NUM_SAO_COMPONENTS; compIdx++) 334 { 335 Bool isLuma = (compIdx == SAO_Y); 336 Int formatShift= isLuma?0:1; 337 338 Int srcStride = isLuma?srcYuv->getStride():srcYuv->getCStride(); 339 Pel* srcBlk = getPicBuf(srcYuv, compIdx)+ (yPos >> formatShift)*srcStride+ (xPos >> formatShift); 340 341 Int orgStride = isLuma?orgYuv->getStride():orgYuv->getCStride(); 342 Pel* orgBlk = getPicBuf(orgYuv, compIdx)+ (yPos >> formatShift)*orgStride+ (xPos >> formatShift); 343 344 getBlkStats(compIdx, blkStats[ctu][compIdx] 345 , srcBlk, orgBlk, srcStride, orgStride, (width >> formatShift), (height >> formatShift) 346 , isLeftAvail, isRightAvail, isAboveAvail, isBelowAvail, isAboveLeftAvail, isAboveRightAvail, isBelowLeftAvail, isBelowRightAvail 347 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 348 , isCalculatePreDeblockSamples 349 #endif 350 ); 351 352 } 353 } 354 } 355 356 Void TEncSampleAdaptiveOffset::decidePicParams(Bool* sliceEnabled, Int picTempLayer) 357 { 358 //decide sliceEnabled[compIdx] 359 for (Int compIdx=0; compIdx<NUM_SAO_COMPONENTS; compIdx++) 360 { 361 // reset flags & counters 362 sliceEnabled[compIdx] = true; 363 364 #if SAO_ENCODING_CHOICE 365 #if SAO_ENCODING_CHOICE_CHROMA 366 // decide slice-level on/off based on previous results 367 if( (picTempLayer > 0) 368 && (m_saoDisabledRate[compIdx][picTempLayer-1] > ((compIdx==SAO_Y) ? SAO_ENCODING_RATE : SAO_ENCODING_RATE_CHROMA)) ) 369 { 370 sliceEnabled[compIdx] = false; 371 } 372 #else 373 // decide slice-level on/off based on previous results 374 if( (picTempLayer > 0) 375 && (m_saoDisabledRate[SAO_Y][0] > SAO_ENCODING_RATE) ) 376 { 377 sliceEnabled[compIdx] = false; 378 } 379 #endif 380 #endif 381 } 382 } 383 384 Int64 TEncSampleAdaptiveOffset::getDistortion(Int ctu, Int compIdx, Int typeIdc, Int typeAuxInfo, Int* invQuantOffset, SAOStatData& statData) 385 { 386 Int64 dist=0; 387 Int inputBitDepth = (compIdx == SAO_Y) ? g_bitDepthY : g_bitDepthC ; 388 Int shift = 2 * DISTORTION_PRECISION_ADJUSTMENT(inputBitDepth-8); 389 390 switch(typeIdc) 391 { 392 case SAO_TYPE_EO_0: 393 case SAO_TYPE_EO_90: 394 case SAO_TYPE_EO_135: 395 case SAO_TYPE_EO_45: 396 { 397 for (Int offsetIdx=0; offsetIdx<NUM_SAO_EO_CLASSES; offsetIdx++) 398 { 399 dist += estSaoDist( statData.count[offsetIdx], invQuantOffset[offsetIdx], statData.diff[offsetIdx], shift); 400 } 401 } 402 break; 403 case SAO_TYPE_BO: 404 { 405 for (Int offsetIdx=typeAuxInfo; offsetIdx<typeAuxInfo+4; offsetIdx++) 406 { 407 Int bandIdx = offsetIdx % NUM_SAO_BO_CLASSES ; 408 dist += estSaoDist( statData.count[bandIdx], invQuantOffset[bandIdx], statData.diff[bandIdx], shift); 409 } 410 } 411 break; 412 default: 413 { 414 printf("Not a supported type"); 415 assert(0); 416 exit(-1); 417 } 418 } 419 420 return dist; 421 } 422 423 inline Int64 TEncSampleAdaptiveOffset::estSaoDist(Int64 count, Int64 offset, Int64 diffSum, Int shift) 424 { 425 return (( count*offset*offset-diffSum*offset*2 ) >> shift); 426 } 427 428 429 inline Int TEncSampleAdaptiveOffset::estIterOffset(Int typeIdx, Int classIdx, Double lambda, Int offsetInput, Int64 count, Int64 diffSum, Int shift, Int bitIncrease, Int64& bestDist, Double& bestCost, Int offsetTh ) 430 { 431 Int iterOffset, tempOffset; 432 Int64 tempDist, tempRate; 433 Double tempCost, tempMinCost; 434 Int offsetOutput = 0; 435 iterOffset = offsetInput; 436 // 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. 437 tempMinCost = lambda; 438 while (iterOffset != 0) 439 { 440 // Calculate the bits required for signaling the offset 441 tempRate = (typeIdx == SAO_TYPE_BO) ? (abs((Int)iterOffset)+2) : (abs((Int)iterOffset)+1); 442 if (abs((Int)iterOffset)==offsetTh) //inclusive 443 { 444 tempRate --; 445 } 446 // Do the dequantization before distortion calculation 447 tempOffset = iterOffset << bitIncrease; 448 tempDist = estSaoDist( count, tempOffset, diffSum, shift); 449 tempCost = ((Double)tempDist + lambda * (Double) tempRate); 450 if(tempCost < tempMinCost) 451 { 452 tempMinCost = tempCost; 453 offsetOutput = iterOffset; 454 bestDist = tempDist; 455 bestCost = tempCost; 456 } 457 iterOffset = (iterOffset > 0) ? (iterOffset-1):(iterOffset+1); 458 } 459 return offsetOutput; 460 } 461 462 463 Void TEncSampleAdaptiveOffset::deriveOffsets(Int ctu, Int compIdx, Int typeIdc, SAOStatData& statData, Int* quantOffsets, Int& typeAuxInfo) 464 { 465 Int bitDepth = (compIdx== SAO_Y) ? g_bitDepthY : g_bitDepthC; 466 Int shift = 2 * DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8); 467 Int offsetTh = g_saoMaxOffsetQVal[compIdx]; //inclusive 468 469 ::memset(quantOffsets, 0, sizeof(Int)*MAX_NUM_SAO_CLASSES); 470 471 //derive initial offsets 472 Int numClasses = (typeIdc == SAO_TYPE_BO)?((Int)NUM_SAO_BO_CLASSES):((Int)NUM_SAO_EO_CLASSES); 473 for(Int classIdx=0; classIdx< numClasses; classIdx++) 474 { 475 if( (typeIdc != SAO_TYPE_BO) && (classIdx==SAO_CLASS_EO_PLAIN) ) 476 { 477 continue; //offset will be zero 478 } 479 480 if(statData.count[classIdx] == 0) 481 { 482 continue; //offset will be zero 483 } 484 485 quantOffsets[classIdx] = (Int) xRoundIbdi(bitDepth, (Double)( statData.diff[classIdx]<<(bitDepth-8)) 486 / 487 (Double)( statData.count[classIdx]<< m_offsetStepLog2[compIdx]) 488 ); 489 quantOffsets[classIdx] = Clip3(-offsetTh, offsetTh, quantOffsets[classIdx]); 490 } 491 492 // adjust offsets 493 switch(typeIdc) 494 { 495 case SAO_TYPE_EO_0: 496 case SAO_TYPE_EO_90: 497 case SAO_TYPE_EO_135: 498 case SAO_TYPE_EO_45: 499 { 500 Int64 classDist; 501 Double classCost; 502 for(Int classIdx=0; classIdx<NUM_SAO_EO_CLASSES; classIdx++) 503 { 504 if(classIdx==SAO_CLASS_EO_FULL_VALLEY && quantOffsets[classIdx] < 0) quantOffsets[classIdx] =0; 505 if(classIdx==SAO_CLASS_EO_HALF_VALLEY && quantOffsets[classIdx] < 0) quantOffsets[classIdx] =0; 506 if(classIdx==SAO_CLASS_EO_HALF_PEAK && quantOffsets[classIdx] > 0) quantOffsets[classIdx] =0; 507 if(classIdx==SAO_CLASS_EO_FULL_PEAK && quantOffsets[classIdx] > 0) quantOffsets[classIdx] =0; 508 509 if( quantOffsets[classIdx] != 0 ) //iterative adjustment only when derived offset is not zero 510 { 511 quantOffsets[classIdx] = estIterOffset( typeIdc, classIdx, m_labmda[compIdx], quantOffsets[classIdx], statData.count[classIdx], statData.diff[classIdx], shift, m_offsetStepLog2[compIdx], classDist , classCost , offsetTh ); 512 } 513 } 514 515 typeAuxInfo =0; 516 } 517 break; 518 case SAO_TYPE_BO: 519 { 520 Int64 distBOClasses[NUM_SAO_BO_CLASSES]; 521 Double costBOClasses[NUM_SAO_BO_CLASSES]; 522 ::memset(distBOClasses, 0, sizeof(Int64)*NUM_SAO_BO_CLASSES); 523 for(Int classIdx=0; classIdx< NUM_SAO_BO_CLASSES; classIdx++) 524 { 525 costBOClasses[classIdx]= m_labmda[compIdx]; 526 if( quantOffsets[classIdx] != 0 ) //iterative adjustment only when derived offset is not zero 527 { 528 quantOffsets[classIdx] = estIterOffset( typeIdc, classIdx, m_labmda[compIdx], quantOffsets[classIdx], statData.count[classIdx], statData.diff[classIdx], shift, m_offsetStepLog2[compIdx], distBOClasses[classIdx], costBOClasses[classIdx], offsetTh ); 529 } 530 } 531 532 //decide the starting band index 533 Double minCost = MAX_DOUBLE, cost; 534 for(Int band=0; band< NUM_SAO_BO_CLASSES- 4+ 1; band++) 535 { 536 cost = costBOClasses[band ]; 537 cost += costBOClasses[band+1]; 538 cost += costBOClasses[band+2]; 539 cost += costBOClasses[band+3]; 540 541 if(cost < minCost) 542 { 543 minCost = cost; 544 typeAuxInfo = band; 545 } 546 } 547 //clear those unused classes 548 Int clearQuantOffset[NUM_SAO_BO_CLASSES]; 549 ::memset(clearQuantOffset, 0, sizeof(Int)*NUM_SAO_BO_CLASSES); 550 for(Int i=0; i< 4; i++) 551 { 552 Int band = (typeAuxInfo+i)%NUM_SAO_BO_CLASSES; 553 clearQuantOffset[band] = quantOffsets[band]; 554 } 555 ::memcpy(quantOffsets, clearQuantOffset, sizeof(Int)*NUM_SAO_BO_CLASSES); 556 } 557 break; 558 default: 559 { 560 printf("Not a supported type"); 561 assert(0); 562 exit(-1); 563 } 564 565 } 566 567 568 } 569 570 571 Void TEncSampleAdaptiveOffset::deriveModeNewRDO(Int ctu, std::vector<SAOBlkParam*>& mergeList, Bool* sliceEnabled, SAOStatData*** blkStats, SAOBlkParam& modeParam, Double& modeNormCost, TEncSbac** cabacCoderRDO, Int inCabacLabel) 572 { 573 Double minCost, cost; 574 Int rate, minRate; 575 Int64 dist[NUM_SAO_COMPONENTS], modeDist[NUM_SAO_COMPONENTS]; 576 SAOOffset testOffset[NUM_SAO_COMPONENTS]; 577 Int compIdx; 578 Int invQuantOffset[MAX_NUM_SAO_CLASSES]; 579 580 modeDist[SAO_Y]= modeDist[SAO_Cb] = modeDist[SAO_Cr] = 0; 581 582 //pre-encode merge flags 583 modeParam[SAO_Y ].modeIdc = SAO_MODE_OFF; 584 m_pcRDGoOnSbacCoder->load(cabacCoderRDO[inCabacLabel]); 585 m_pcRDGoOnSbacCoder->codeSAOBlkParam(modeParam, sliceEnabled, (mergeList[SAO_MERGE_LEFT]!= NULL), (mergeList[SAO_MERGE_ABOVE]!= NULL), true); 586 m_pcRDGoOnSbacCoder->store(cabacCoderRDO[SAO_CABACSTATE_BLK_MID]); 587 588 //------ luma --------// 589 compIdx = SAO_Y; 590 //"off" case as initial cost 591 modeParam[compIdx].modeIdc = SAO_MODE_OFF; 592 m_pcRDGoOnSbacCoder->resetBits(); 593 m_pcRDGoOnSbacCoder->codeSAOOffsetParam(compIdx, modeParam[compIdx], sliceEnabled[compIdx]); 594 minRate= m_pcRDGoOnSbacCoder->getNumberOfWrittenBits(); 595 modeDist[compIdx] = 0; 596 minCost= m_labmda[compIdx]*((Double)minRate); 597 m_pcRDGoOnSbacCoder->store(cabacCoderRDO[SAO_CABACSTATE_BLK_TEMP]); 598 if(sliceEnabled[compIdx]) 599 { 600 for(Int typeIdc=0; typeIdc< NUM_SAO_NEW_TYPES; typeIdc++) 601 { 602 testOffset[compIdx].modeIdc = SAO_MODE_NEW; 603 testOffset[compIdx].typeIdc = typeIdc; 604 605 //derive coded offset 606 deriveOffsets(ctu, compIdx, typeIdc, blkStats[ctu][compIdx][typeIdc], testOffset[compIdx].offset, testOffset[compIdx].typeAuxInfo); 607 608 //inversed quantized offsets 609 invertQuantOffsets(compIdx, typeIdc, testOffset[compIdx].typeAuxInfo, invQuantOffset, testOffset[compIdx].offset); 610 611 //get distortion 612 dist[compIdx] = getDistortion(ctu, compIdx, testOffset[compIdx].typeIdc, testOffset[compIdx].typeAuxInfo, invQuantOffset, blkStats[ctu][compIdx][typeIdc]); 613 614 //get rate 615 m_pcRDGoOnSbacCoder->load(cabacCoderRDO[SAO_CABACSTATE_BLK_MID]); 616 m_pcRDGoOnSbacCoder->resetBits(); 617 m_pcRDGoOnSbacCoder->codeSAOOffsetParam(compIdx, testOffset[compIdx], sliceEnabled[compIdx]); 618 rate = m_pcRDGoOnSbacCoder->getNumberOfWrittenBits(); 619 cost = (Double)dist[compIdx] + m_labmda[compIdx]*((Double)rate); 620 if(cost < minCost) 621 { 622 minCost = cost; 623 minRate = rate; 624 modeDist[compIdx] = dist[compIdx]; 625 modeParam[compIdx]= testOffset[compIdx]; 626 m_pcRDGoOnSbacCoder->store(cabacCoderRDO[SAO_CABACSTATE_BLK_TEMP]); 627 } 628 } 629 } 630 m_pcRDGoOnSbacCoder->load(cabacCoderRDO[SAO_CABACSTATE_BLK_TEMP]); 631 m_pcRDGoOnSbacCoder->store(cabacCoderRDO[SAO_CABACSTATE_BLK_MID]); 632 633 //------ chroma --------// 634 assert(m_labmda[SAO_Cb] == m_labmda[SAO_Cr]); 635 Double chromaLambda = m_labmda[SAO_Cb]; 636 //"off" case as initial cost 637 m_pcRDGoOnSbacCoder->resetBits(); 638 modeParam[SAO_Cb].modeIdc = SAO_MODE_OFF; 639 m_pcRDGoOnSbacCoder->codeSAOOffsetParam(SAO_Cb, modeParam[SAO_Cb], sliceEnabled[SAO_Cb]); 640 modeParam[SAO_Cr].modeIdc = SAO_MODE_OFF; 641 m_pcRDGoOnSbacCoder->codeSAOOffsetParam(SAO_Cr, modeParam[SAO_Cr], sliceEnabled[SAO_Cr]); 642 minRate= m_pcRDGoOnSbacCoder->getNumberOfWrittenBits(); 643 modeDist[SAO_Cb] = modeDist[SAO_Cr]= 0; 644 minCost= chromaLambda*((Double)minRate); 645 646 //doesn't need to store cabac status here since the whole CTU parameters will be re-encoded at the end of this function 647 648 for(Int typeIdc=0; typeIdc< NUM_SAO_NEW_TYPES; typeIdc++) 649 { 650 for(compIdx= SAO_Cb; compIdx< NUM_SAO_COMPONENTS; compIdx++) 651 { 652 if(!sliceEnabled[compIdx]) 653 { 654 testOffset[compIdx].modeIdc = SAO_MODE_OFF; 655 dist[compIdx]= 0; 656 continue; 657 } 658 testOffset[compIdx].modeIdc = SAO_MODE_NEW; 659 testOffset[compIdx].typeIdc = typeIdc; 660 661 //derive offset & get distortion 662 deriveOffsets(ctu, compIdx, typeIdc, blkStats[ctu][compIdx][typeIdc], testOffset[compIdx].offset, testOffset[compIdx].typeAuxInfo); 663 invertQuantOffsets(compIdx, typeIdc, testOffset[compIdx].typeAuxInfo, invQuantOffset, testOffset[compIdx].offset); 664 dist[compIdx]= getDistortion(ctu, compIdx, typeIdc, testOffset[compIdx].typeAuxInfo, invQuantOffset, blkStats[ctu][compIdx][typeIdc]); 665 } 666 667 //get rate 668 m_pcRDGoOnSbacCoder->load(cabacCoderRDO[SAO_CABACSTATE_BLK_MID]); 669 m_pcRDGoOnSbacCoder->resetBits(); 670 m_pcRDGoOnSbacCoder->codeSAOOffsetParam(SAO_Cb, testOffset[SAO_Cb], sliceEnabled[SAO_Cb]); 671 m_pcRDGoOnSbacCoder->codeSAOOffsetParam(SAO_Cr, testOffset[SAO_Cr], sliceEnabled[SAO_Cr]); 672 rate = m_pcRDGoOnSbacCoder->getNumberOfWrittenBits(); 673 674 cost = (Double)(dist[SAO_Cb]+ dist[SAO_Cr]) + chromaLambda*((Double)rate); 675 if(cost < minCost) 676 { 677 minCost = cost; 678 minRate = rate; 679 modeDist[SAO_Cb] = dist[SAO_Cb]; 680 modeDist[SAO_Cr] = dist[SAO_Cr]; 681 modeParam[SAO_Cb]= testOffset[SAO_Cb]; 682 modeParam[SAO_Cr]= testOffset[SAO_Cr]; 683 } 684 } 685 686 687 //----- re-gen rate & normalized cost----// 688 modeNormCost = (Double)modeDist[SAO_Y]/m_labmda[SAO_Y]; 689 modeNormCost += (Double)(modeDist[SAO_Cb]+ modeDist[SAO_Cr])/chromaLambda; 690 m_pcRDGoOnSbacCoder->load(cabacCoderRDO[inCabacLabel]); 691 m_pcRDGoOnSbacCoder->resetBits(); 692 m_pcRDGoOnSbacCoder->codeSAOBlkParam(modeParam, sliceEnabled, (mergeList[SAO_MERGE_LEFT]!= NULL), (mergeList[SAO_MERGE_ABOVE]!= NULL), false); 693 modeNormCost += (Double)m_pcRDGoOnSbacCoder->getNumberOfWrittenBits(); 694 695 } 696 697 Void TEncSampleAdaptiveOffset::deriveModeMergeRDO(Int ctu, std::vector<SAOBlkParam*>& mergeList, Bool* sliceEnabled, SAOStatData*** blkStats, SAOBlkParam& modeParam, Double& modeNormCost, TEncSbac** cabacCoderRDO, Int inCabacLabel) 698 { 699 Int mergeListSize = (Int)mergeList.size(); 700 modeNormCost = MAX_DOUBLE; 701 702 Double cost; 703 SAOBlkParam testBlkParam; 704 705 for(Int mergeType=0; mergeType< mergeListSize; mergeType++) 706 { 707 if(mergeList[mergeType] == NULL) 708 { 709 continue; 710 } 711 712 testBlkParam = *(mergeList[mergeType]); 713 //normalized distortion 714 Double normDist=0; 715 for(Int compIdx=0; compIdx< NUM_SAO_COMPONENTS; compIdx++) 716 { 717 testBlkParam[compIdx].modeIdc = SAO_MODE_MERGE; 718 testBlkParam[compIdx].typeIdc = mergeType; 719 720 SAOOffset& mergedOffsetParam = (*(mergeList[mergeType]))[compIdx]; 721 722 if( mergedOffsetParam.modeIdc != SAO_MODE_OFF) 723 { 724 //offsets have been reconstructed. Don't call inversed quantization function. 725 normDist += (((Double)getDistortion(ctu, compIdx, mergedOffsetParam.typeIdc, mergedOffsetParam.typeAuxInfo, mergedOffsetParam.offset, blkStats[ctu][compIdx][mergedOffsetParam.typeIdc])) 726 /m_labmda[compIdx] 727 ); 728 } 729 730 } 731 732 //rate 733 m_pcRDGoOnSbacCoder->load(cabacCoderRDO[inCabacLabel]); 734 m_pcRDGoOnSbacCoder->resetBits(); 735 m_pcRDGoOnSbacCoder->codeSAOBlkParam(testBlkParam, sliceEnabled, (mergeList[SAO_MERGE_LEFT]!= NULL), (mergeList[SAO_MERGE_ABOVE]!= NULL), false); 736 Int rate = m_pcRDGoOnSbacCoder->getNumberOfWrittenBits(); 737 738 cost = normDist+(Double)rate; 739 740 if(cost < modeNormCost) 741 { 742 modeNormCost = cost; 743 modeParam = testBlkParam; 744 m_pcRDGoOnSbacCoder->store(cabacCoderRDO[SAO_CABACSTATE_BLK_TEMP]); 745 } 746 } 747 748 m_pcRDGoOnSbacCoder->load(cabacCoderRDO[SAO_CABACSTATE_BLK_TEMP]); 749 750 751 } 752 753 Void TEncSampleAdaptiveOffset::decideBlkParams(TComPic* pic, Bool* sliceEnabled, SAOStatData*** blkStats, TComPicYuv* srcYuv, TComPicYuv* resYuv, SAOBlkParam* reconParams, SAOBlkParam* codedParams) 754 { 755 Bool isAllBlksDisabled = false; 756 if(!sliceEnabled[SAO_Y] && !sliceEnabled[SAO_Cb] && !sliceEnabled[SAO_Cr]) 757 { 758 isAllBlksDisabled = true; 759 } 760 761 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[ SAO_CABACSTATE_PIC_INIT ]); 762 763 SAOBlkParam modeParam; 764 Double minCost, modeCost; 765 766 for(Int ctu=0; ctu< m_numCTUsPic; ctu++) 767 { 768 if(isAllBlksDisabled) 769 { 770 codedParams[ctu].reset(); 771 continue; 772 } 773 774 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[ SAO_CABACSTATE_BLK_CUR ]); 775 776 //get merge list 777 std::vector<SAOBlkParam*> mergeList; 778 getMergeList(pic, ctu, reconParams, mergeList); 779 780 minCost = MAX_DOUBLE; 781 for(Int mode=0; mode < NUM_SAO_MODES; mode++) 782 { 783 switch(mode) 784 { 785 case SAO_MODE_OFF: 786 { 787 continue; //not necessary, since all-off case will be tested in SAO_MODE_NEW case. 788 } 789 break; 790 case SAO_MODE_NEW: 791 { 792 deriveModeNewRDO(ctu, mergeList, sliceEnabled, blkStats, modeParam, modeCost, m_pppcRDSbacCoder, SAO_CABACSTATE_BLK_CUR); 793 794 } 795 break; 796 case SAO_MODE_MERGE: 797 { 798 deriveModeMergeRDO(ctu, mergeList, sliceEnabled, blkStats , modeParam, modeCost, m_pppcRDSbacCoder, SAO_CABACSTATE_BLK_CUR); 799 } 800 break; 801 default: 802 { 803 printf("Not a supported SAO mode\n"); 804 assert(0); 805 exit(-1); 806 } 807 } 808 809 if(modeCost < minCost) 810 { 811 minCost = modeCost; 812 codedParams[ctu] = modeParam; 813 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[ SAO_CABACSTATE_BLK_NEXT ]); 814 815 } 816 } //mode 817 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[ SAO_CABACSTATE_BLK_NEXT ]); 818 819 //apply reconstructed offsets 820 reconParams[ctu] = codedParams[ctu]; 821 reconstructBlkSAOParam(reconParams[ctu], mergeList); 822 offsetCTU(ctu, srcYuv, resYuv, reconParams[ctu], pic); 823 } //ctu 824 825 #if SAO_ENCODING_CHOICE 826 Int picTempLayer = pic->getSlice(0)->getDepth(); 827 Int numLcusForSAOOff[NUM_SAO_COMPONENTS]; 828 numLcusForSAOOff[SAO_Y ] = numLcusForSAOOff[SAO_Cb]= numLcusForSAOOff[SAO_Cr]= 0; 829 830 for (Int compIdx=0; compIdx<NUM_SAO_COMPONENTS; compIdx++) 831 { 832 for(Int ctu=0; ctu< m_numCTUsPic; ctu++) 833 { 834 if( reconParams[ctu][compIdx].modeIdc == SAO_MODE_OFF) 835 { 836 numLcusForSAOOff[compIdx]++; 837 } 838 } 839 } 840 #if SAO_ENCODING_CHOICE_CHROMA 841 for (Int compIdx=0; compIdx<NUM_SAO_COMPONENTS; compIdx++) 842 { 843 m_saoDisabledRate[compIdx][picTempLayer] = (Double)numLcusForSAOOff[compIdx]/(Double)m_numCTUsPic; 844 } 845 #else 846 if (picTempLayer == 0) 847 { 848 m_saoDisabledRate[SAO_Y][0] = (Double)(numLcusForSAOOff[SAO_Y]+numLcusForSAOOff[SAO_Cb]+numLcusForSAOOff[SAO_Cr])/(Double)(m_numCTUsPic*3); 849 } 850 #endif 851 #endif 852 } 853 854 855 Void TEncSampleAdaptiveOffset::getBlkStats(Int compIdx, SAOStatData* statsDataTypes 856 , Pel* srcBlk, Pel* orgBlk, Int srcStride, Int orgStride, Int width, Int height 857 , Bool isLeftAvail, Bool isRightAvail, Bool isAboveAvail, Bool isBelowAvail, Bool isAboveLeftAvail, Bool isAboveRightAvail, Bool isBelowLeftAvail, Bool isBelowRightAvail 858 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 859 , Bool isCalculatePreDeblockSamples 860 #endif 861 ) 862 { 863 if(m_lineBufWidth != m_maxCUWidth) 864 { 865 m_lineBufWidth = m_maxCUWidth; 866 867 if (m_signLineBuf1) delete[] m_signLineBuf1; m_signLineBuf1 = NULL; 868 m_signLineBuf1 = new Char[m_lineBufWidth+1]; 869 870 if (m_signLineBuf2) delete[] m_signLineBuf2; m_signLineBuf2 = NULL; 871 m_signLineBuf2 = new Char[m_lineBufWidth+1]; 872 } 873 874 Int x,y, startX, startY, endX, endY, edgeType, firstLineStartX, firstLineEndX; 875 Char signLeft, signRight, signDown; 876 Int64 *diff, *count; 877 Pel *srcLine, *orgLine; 878 Int* skipLinesR = m_skipLinesR[compIdx]; 879 Int* skipLinesB = m_skipLinesB[compIdx]; 880 881 for(Int typeIdx=0; typeIdx< NUM_SAO_NEW_TYPES; typeIdx++) 882 { 883 SAOStatData& statsData= statsDataTypes[typeIdx]; 884 statsData.reset(); 885 886 srcLine = srcBlk; 887 orgLine = orgBlk; 888 diff = statsData.diff; 889 count = statsData.count; 890 switch(typeIdx) 891 { 892 case SAO_TYPE_EO_0: 893 { 894 diff +=2; 895 count+=2; 896 endY = (isBelowAvail) ? (height - skipLinesB[typeIdx]) : height; 897 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 898 startX = (!isCalculatePreDeblockSamples) ? (isLeftAvail ? 0 : 1) 899 : (isRightAvail ? (width - skipLinesR[typeIdx]) : (width - 1)) 900 ; 901 #else 902 startX = isLeftAvail ? 0 : 1; 903 #endif 904 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 905 endX = (!isCalculatePreDeblockSamples) ? (isRightAvail ? (width - skipLinesR[typeIdx]) : (width - 1)) 906 : (isRightAvail ? width : (width - 1)) 907 ; 908 #else 909 endX = isRightAvail ? (width - skipLinesR[typeIdx]): (width - 1); 910 #endif 911 for (y=0; y<endY; y++) 912 { 913 signLeft = (Char)m_sign[srcLine[startX] - srcLine[startX-1]]; 914 for (x=startX; x<endX; x++) 915 { 916 signRight = (Char)m_sign[srcLine[x] - srcLine[x+1]]; 917 edgeType = signRight + signLeft; 918 signLeft = -signRight; 919 920 diff [edgeType] += (orgLine[x] - srcLine[x]); 921 count[edgeType] ++; 922 } 923 srcLine += srcStride; 924 orgLine += orgStride; 925 } 926 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 927 if(isCalculatePreDeblockSamples) 928 { 929 if(isBelowAvail) 930 { 931 startX = isLeftAvail ? 0 : 1; 932 endX = isRightAvail ? width : (width -1); 933 934 for(y=0; y<skipLinesB[typeIdx]; y++) 935 { 936 signLeft = (Char)m_sign[srcLine[startX] - srcLine[startX-1]]; 937 for (x=startX; x<endX; x++) 938 { 939 signRight = (Char)m_sign[srcLine[x] - srcLine[x+1]]; 940 edgeType = signRight + signLeft; 941 signLeft = -signRight; 942 943 diff [edgeType] += (orgLine[x] - srcLine[x]); 944 count[edgeType] ++; 945 } 946 srcLine += srcStride; 947 orgLine += orgStride; 948 } 949 } 950 } 951 #endif 952 } 953 break; 954 case SAO_TYPE_EO_90: 955 { 956 diff +=2; 957 count+=2; 958 Char *signUpLine = m_signLineBuf1; 959 960 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 961 startX = (!isCalculatePreDeblockSamples) ? 0 962 : (isRightAvail ? (width - skipLinesR[typeIdx]) : width) 963 ; 964 #endif 965 startY = isAboveAvail ? 0 : 1; 966 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 967 endX = (!isCalculatePreDeblockSamples) ? (isRightAvail ? (width - skipLinesR[typeIdx]) : width) 968 : width 969 ; 970 #else 971 endX = isRightAvail ? (width - skipLinesR[typeIdx]) : width ; 972 #endif 973 endY = isBelowAvail ? (height - skipLinesB[typeIdx]) : (height - 1); 974 if (!isAboveAvail) 975 { 976 srcLine += srcStride; 977 orgLine += orgStride; 978 } 979 980 Pel* srcLineAbove = srcLine - srcStride; 981 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 982 for (x=startX; x<endX; x++) 983 #else 984 for (x=0; x< endX; x++) 985 #endif 986 { 987 signUpLine[x] = (Char)m_sign[srcLine[x] - srcLineAbove[x]]; 988 } 989 990 Pel* srcLineBelow; 991 for (y=startY; y<endY; y++) 992 { 993 srcLineBelow = srcLine + srcStride; 994 995 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 996 for (x=startX; x<endX; x++) 997 #else 998 for (x=0; x<endX; x++) 999 #endif 1000 { 1001 signDown = (Char)m_sign[srcLine[x] - srcLineBelow[x]]; 1002 edgeType = signDown + signUpLine[x]; 1003 signUpLine[x]= -signDown; 1004 1005 diff [edgeType] += (orgLine[x] - srcLine[x]); 1006 count[edgeType] ++; 1007 } 1008 srcLine += srcStride; 1009 orgLine += orgStride; 1010 } 1011 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1012 if(isCalculatePreDeblockSamples) 1013 { 1014 if(isBelowAvail) 1015 { 1016 startX = 0; 1017 endX = width; 1018 1019 for(y=0; y<skipLinesB[typeIdx]; y++) 1020 { 1021 srcLineBelow = srcLine + srcStride; 1022 srcLineAbove = srcLine - srcStride; 1023 1024 for (x=startX; x<endX; x++) 1025 { 1026 edgeType = m_sign[srcLine[x] - srcLineBelow[x]] + m_sign[srcLine[x] - srcLineAbove[x]]; 1027 diff [edgeType] += (orgLine[x] - srcLine[x]); 1028 count[edgeType] ++; 1029 } 1030 srcLine += srcStride; 1031 orgLine += orgStride; 1032 } 1033 } 1034 } 1035 #endif 1036 1037 } 1038 break; 1039 case SAO_TYPE_EO_135: 1040 { 1041 diff +=2; 1042 count+=2; 1043 Char *signUpLine, *signDownLine, *signTmpLine; 1044 1045 signUpLine = m_signLineBuf1; 1046 signDownLine= m_signLineBuf2; 1047 1048 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1049 startX = (!isCalculatePreDeblockSamples) ? (isLeftAvail ? 0 : 1) 1050 : (isRightAvail ? (width - skipLinesR[typeIdx]) : (width - 1)) 1051 ; 1052 #else 1053 startX = isLeftAvail ? 0 : 1 ; 1054 #endif 1055 1056 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1057 endX = (!isCalculatePreDeblockSamples) ? (isRightAvail ? (width - skipLinesR[typeIdx]): (width - 1)) 1058 : (isRightAvail ? width : (width - 1)) 1059 ; 1060 #else 1061 endX = isRightAvail ? (width - skipLinesR[typeIdx]): (width - 1); 1062 #endif 1063 endY = isBelowAvail ? (height - skipLinesB[typeIdx]) : (height - 1); 1064 1065 //prepare 2nd line's upper sign 1066 Pel* srcLineBelow = srcLine + srcStride; 1067 for (x=startX; x<endX+1; x++) 1068 { 1069 signUpLine[x] = (Char)m_sign[srcLineBelow[x] - srcLine[x-1]]; 1070 } 1071 1072 //1st line 1073 Pel* srcLineAbove = srcLine - srcStride; 1074 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1075 firstLineStartX = (!isCalculatePreDeblockSamples) ? (isAboveLeftAvail ? 0 : 1) : startX; 1076 firstLineEndX = (!isCalculatePreDeblockSamples) ? (isAboveAvail ? endX : 1) : endX; 1077 #else 1078 firstLineStartX = isAboveLeftAvail ? 0 : 1; 1079 firstLineEndX = isAboveAvail ? endX : 1; 1080 #endif 1081 for(x=firstLineStartX; x<firstLineEndX; x++) 1082 { 1083 edgeType = m_sign[srcLine[x] - srcLineAbove[x-1]] - signUpLine[x+1]; 1084 diff [edgeType] += (orgLine[x] - srcLine[x]); 1085 count[edgeType] ++; 1086 } 1087 srcLine += srcStride; 1088 orgLine += orgStride; 1089 1090 1091 //middle lines 1092 for (y=1; y<endY; y++) 1093 { 1094 srcLineBelow = srcLine + srcStride; 1095 1096 for (x=startX; x<endX; x++) 1097 { 1098 signDown = (Char)m_sign[srcLine[x] - srcLineBelow[x+1]] ; 1099 edgeType = signDown + signUpLine[x]; 1100 diff [edgeType] += (orgLine[x] - srcLine[x]); 1101 count[edgeType] ++; 1102 1103 signDownLine[x+1] = -signDown; 1104 } 1105 signDownLine[startX] = (Char)m_sign[srcLineBelow[startX] - srcLine[startX-1]]; 1106 1107 signTmpLine = signUpLine; 1108 signUpLine = signDownLine; 1109 signDownLine = signTmpLine; 1110 1111 srcLine += srcStride; 1112 orgLine += orgStride; 1113 } 1114 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1115 if(isCalculatePreDeblockSamples) 1116 { 1117 if(isBelowAvail) 1118 { 1119 startX = isLeftAvail ? 0 : 1 ; 1120 endX = isRightAvail ? width : (width -1); 1121 1122 for(y=0; y<skipLinesB[typeIdx]; y++) 1123 { 1124 srcLineBelow = srcLine + srcStride; 1125 srcLineAbove = srcLine - srcStride; 1126 1127 for (x=startX; x< endX; x++) 1128 { 1129 edgeType = m_sign[srcLine[x] - srcLineBelow[x+1]] + m_sign[srcLine[x] - srcLineAbove[x-1]]; 1130 diff [edgeType] += (orgLine[x] - srcLine[x]); 1131 count[edgeType] ++; 1132 } 1133 srcLine += srcStride; 1134 orgLine += orgStride; 1135 } 1136 } 1137 } 1138 #endif 1139 } 1140 break; 1141 case SAO_TYPE_EO_45: 1142 { 1143 diff +=2; 1144 count+=2; 1145 Char *signUpLine = m_signLineBuf1+1; 1146 1147 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1148 startX = (!isCalculatePreDeblockSamples) ? (isLeftAvail ? 0 : 1) 1149 : (isRightAvail ? (width - skipLinesR[typeIdx]) : (width - 1)) 1150 ; 1151 #else 1152 startX = isLeftAvail ? 0 : 1; 1153 #endif 1154 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1155 endX = (!isCalculatePreDeblockSamples) ? (isRightAvail ? (width - skipLinesR[typeIdx]) : (width - 1)) 1156 : (isRightAvail ? width : (width - 1)) 1157 ; 1158 #else 1159 endX = isRightAvail ? (width - skipLinesR[typeIdx]) : (width - 1); 1160 #endif 1161 endY = isBelowAvail ? (height - skipLinesB[typeIdx]) : (height - 1); 1162 1163 //prepare 2nd line upper sign 1164 Pel* srcLineBelow = srcLine + srcStride; 1165 for (x=startX-1; x<endX; x++) 1166 { 1167 signUpLine[x] = (Char)m_sign[srcLineBelow[x] - srcLine[x+1]]; 1168 } 1169 1170 1171 //first line 1172 Pel* srcLineAbove = srcLine - srcStride; 1173 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1174 firstLineStartX = (!isCalculatePreDeblockSamples) ? (isAboveAvail ? startX : endX) 1175 : startX 1176 ; 1177 firstLineEndX = (!isCalculatePreDeblockSamples) ? ((!isRightAvail && isAboveRightAvail) ? width : endX) 1178 : endX 1179 ; 1180 #else 1181 firstLineStartX = isAboveAvail ? startX : endX; 1182 firstLineEndX = (!isRightAvail && isAboveRightAvail) ? width : endX; 1183 #endif 1184 for(x=firstLineStartX; x<firstLineEndX; x++) 1185 { 1186 edgeType = m_sign[srcLine[x] - srcLineAbove[x+1]] - signUpLine[x-1]; 1187 diff [edgeType] += (orgLine[x] - srcLine[x]); 1188 count[edgeType] ++; 1189 } 1190 1191 srcLine += srcStride; 1192 orgLine += orgStride; 1193 1194 //middle lines 1195 for (y=1; y<endY; y++) 1196 { 1197 srcLineBelow = srcLine + srcStride; 1198 1199 for(x=startX; x<endX; x++) 1200 { 1201 signDown = (Char)m_sign[srcLine[x] - srcLineBelow[x-1]] ; 1202 edgeType = signDown + signUpLine[x]; 1203 1204 diff [edgeType] += (orgLine[x] - srcLine[x]); 1205 count[edgeType] ++; 1206 1207 signUpLine[x-1] = -signDown; 1208 } 1209 signUpLine[endX-1] = (Char)m_sign[srcLineBelow[endX-1] - srcLine[endX]]; 1210 srcLine += srcStride; 1211 orgLine += orgStride; 1212 } 1213 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1214 if(isCalculatePreDeblockSamples) 1215 { 1216 if(isBelowAvail) 1217 { 1218 startX = isLeftAvail ? 0 : 1 ; 1219 endX = isRightAvail ? width : (width -1); 1220 1221 for(y=0; y<skipLinesB[typeIdx]; y++) 1222 { 1223 srcLineBelow = srcLine + srcStride; 1224 srcLineAbove = srcLine - srcStride; 1225 1226 for (x=startX; x<endX; x++) 1227 { 1228 edgeType = m_sign[srcLine[x] - srcLineBelow[x-1]] + m_sign[srcLine[x] - srcLineAbove[x+1]]; 1229 diff [edgeType] += (orgLine[x] - srcLine[x]); 1230 count[edgeType] ++; 1231 } 1232 srcLine += srcStride; 1233 orgLine += orgStride; 1234 } 1235 } 1236 } 1237 #endif 1238 } 1239 break; 1240 case SAO_TYPE_BO: 1241 { 1242 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1243 startX = (!isCalculatePreDeblockSamples)?0 1244 :( isRightAvail?(width- skipLinesR[typeIdx]):width) 1245 ; 1246 endX = (!isCalculatePreDeblockSamples)?(isRightAvail ? (width - skipLinesR[typeIdx]) : width ) 1247 :width 1248 ; 1249 #else 1250 endX = isRightAvail ? (width- skipLinesR[typeIdx]) : width; 1251 #endif 1252 endY = isBelowAvail ? (height- skipLinesB[typeIdx]) : height; 1253 Int shiftBits = ((compIdx == SAO_Y)?g_bitDepthY:g_bitDepthC)- NUM_SAO_BO_CLASSES_LOG2; 1254 for (y=0; y< endY; y++) 1255 { 1256 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1257 for (x=startX; x< endX; x++) 1258 #else 1259 for (x=0; x< endX; x++) 1260 #endif 1261 { 1262 1263 Int bandIdx= srcLine[x] >> shiftBits; 1264 diff [bandIdx] += (orgLine[x] - srcLine[x]); 1265 count[bandIdx] ++; 1266 } 1267 srcLine += srcStride; 1268 orgLine += orgStride; 1269 } 1270 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1271 if(isCalculatePreDeblockSamples) 1272 { 1273 if(isBelowAvail) 1274 { 1275 startX = 0; 1276 endX = width; 1277 1278 for(y= 0; y< skipLinesB[typeIdx]; y++) 1279 { 1280 for (x=startX; x< endX; x++) 1281 { 1282 Int bandIdx= srcLine[x] >> shiftBits; 1283 diff [bandIdx] += (orgLine[x] - srcLine[x]); 1284 count[bandIdx] ++; 1285 } 1286 srcLine += srcStride; 1287 orgLine += orgStride; 1288 1289 } 1290 1291 } 1292 } 1293 #endif 1294 } 1295 break; 1296 default: 1297 { 1298 printf("Not a supported SAO types\n"); 1299 assert(0); 1300 exit(-1); 1301 } 1302 } 1303 } 1304 } 1305 1306 #else 1307 1308 1309 47 1310 TEncSampleAdaptiveOffset::TEncSampleAdaptiveOffset() 48 1311 { … … 1661 2924 } 1662 2925 1663 #if SAO_CHROMA_LAMBDA1664 2926 /** Sample adaptive offset process 1665 2927 * \param pcSaoParam … … 1671 2933 #else 1672 2934 Void TEncSampleAdaptiveOffset::SAOProcess(SAOParam *pcSaoParam, Double dLambdaLuma, Double dLambdaChroma) 1673 #endif1674 #else1675 /** Sample adaptive offset process1676 * \param dLambda1677 */1678 Void TEncSampleAdaptiveOffset::SAOProcess(SAOParam *pcSaoParam, Double dLambda)1679 2935 #endif 1680 2936 { … … 2501 3757 } 2502 3758 3759 #endif 3760 2503 3761 //! \} -
trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h
r313 r540 53 53 // Class definition 54 54 // ==================================================================================================================== 55 56 #if HM_CLEANUP_SAO 57 enum SAOCabacStateLablesRDO //CABAC state labels 58 { 59 SAO_CABACSTATE_PIC_INIT =0, 60 SAO_CABACSTATE_BLK_CUR, 61 SAO_CABACSTATE_BLK_NEXT, 62 SAO_CABACSTATE_BLK_MID, 63 SAO_CABACSTATE_BLK_TEMP, 64 NUM_SAO_CABACSTATE_LABELS 65 }; 66 67 struct SAOStatData //data structure for SAO statistics 68 { 69 Int64 diff[MAX_NUM_SAO_CLASSES]; 70 Int64 count[MAX_NUM_SAO_CLASSES]; 71 72 SAOStatData(){} 73 ~SAOStatData(){} 74 Void reset() 75 { 76 ::memset(diff, 0, sizeof(Int64)*MAX_NUM_SAO_CLASSES); 77 ::memset(count, 0, sizeof(Int64)*MAX_NUM_SAO_CLASSES); 78 } 79 const SAOStatData& operator=(const SAOStatData& src) 80 { 81 ::memcpy(diff, src.diff, sizeof(Int64)*MAX_NUM_SAO_CLASSES); 82 ::memcpy(count, src.count, sizeof(Int64)*MAX_NUM_SAO_CLASSES); 83 return *this; 84 } 85 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 86 const SAOStatData& operator+= (const SAOStatData& src) 87 { 88 for(Int i=0; i< MAX_NUM_SAO_CLASSES; i++) 89 { 90 diff[i] += src.diff[i]; 91 count[i] += src.count[i]; 92 } 93 return *this; 94 } 95 #endif 96 }; 97 98 class TEncSampleAdaptiveOffset : public TComSampleAdaptiveOffset 99 { 100 public: 101 TEncSampleAdaptiveOffset(); 102 virtual ~TEncSampleAdaptiveOffset(); 103 104 //interface 105 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 106 Void createEncData(Bool isPreDBFSamplesUsed); 107 #else 108 Void createEncData(); 109 #endif 110 Void destroyEncData(); 111 Void initRDOCabacCoder(TEncSbac* pcRDGoOnSbacCoder, TComSlice* pcSlice) ; 112 Void SAOProcess(TComPic* pPic, Bool* sliceEnabled, const Double *lambdas 113 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 114 , Bool isPreDBFSamplesUsed 115 #endif 116 ); 117 public: //methods 118 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 119 Void getPreDBFStatistics(TComPic* pPic); 120 #endif 121 private: //methods 122 Void getStatistics(SAOStatData*** blkStats, TComPicYuv* orgYuv, TComPicYuv* srcYuv,TComPic* pPic 123 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 124 , Bool isCalculatePreDeblockSamples = false 125 #endif 126 ); 127 Void decidePicParams(Bool* sliceEnabled, Int picTempLayer); 128 Void decideBlkParams(TComPic* pic, Bool* sliceEnabled, SAOStatData*** blkStats, TComPicYuv* srcYuv, TComPicYuv* resYuv, SAOBlkParam* reconParams, SAOBlkParam* codedParams); 129 Void getBlkStats(Int compIdx, SAOStatData* statsDataTypes, Pel* srcBlk, Pel* orgBlk, Int srcStride, Int orgStride, Int width, Int height, Bool isLeftAvail, Bool isRightAvail, Bool isAboveAvail, Bool isBelowAvail, Bool isAboveLeftAvail, Bool isAboveRightAvail, Bool isBelowLeftAvail, Bool isBelowRightAvail 130 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 131 , Bool isCalculatePreDeblockSamples 132 #endif 133 ); 134 Void deriveModeNewRDO(Int ctu, std::vector<SAOBlkParam*>& mergeList, Bool* sliceEnabled, SAOStatData*** blkStats, SAOBlkParam& modeParam, Double& modeNormCost, TEncSbac** cabacCoderRDO, Int inCabacLabel); 135 Void deriveModeMergeRDO(Int ctu, std::vector<SAOBlkParam*>& mergeList, Bool* sliceEnabled, SAOStatData*** blkStats, SAOBlkParam& modeParam, Double& modeNormCost, TEncSbac** cabacCoderRDO, Int inCabacLabel); 136 Int64 getDistortion(Int ctu, Int compIdx, Int typeIdc, Int typeAuxInfo, Int* offsetVal, SAOStatData& statData); 137 Void deriveOffsets(Int ctu, Int compIdx, Int typeIdc, SAOStatData& statData, Int* quantOffsets, Int& typeAuxInfo); 138 inline Int64 estSaoDist(Int64 count, Int64 offset, Int64 diffSum, Int shift); 139 inline Int estIterOffset(Int typeIdx, Int classIdx, Double lambda, Int offsetInput, Int64 count, Int64 diffSum, Int shift, Int bitIncrease, Int64& bestDist, Double& bestCost, Int offsetTh ); 140 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 141 Void addPreDBFStatistics(SAOStatData*** blkStats); 142 #endif 143 private: //members 144 //for RDO 145 TEncSbac** m_pppcRDSbacCoder; 146 TEncSbac* m_pcRDGoOnSbacCoder; 147 TEncBinCABACCounter** m_pppcBinCoderCABAC; 148 Double m_labmda[NUM_SAO_COMPONENTS]; 149 150 //statistics 151 SAOStatData*** m_statData; //[ctu][comp][classes] 152 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 153 SAOStatData*** m_preDBFstatData; 154 #endif 155 #if SAO_ENCODING_CHOICE 156 Double m_saoDisabledRate[NUM_SAO_COMPONENTS][MAX_TLAYER]; 157 #endif 158 Int m_skipLinesR[NUM_SAO_COMPONENTS][NUM_SAO_NEW_TYPES]; 159 Int m_skipLinesB[NUM_SAO_COMPONENTS][NUM_SAO_NEW_TYPES]; 160 }; 161 #else 162 55 163 56 164 class TEncSampleAdaptiveOffset : public TComSampleAdaptiveOffset … … 95 203 Void endSaoEnc(); 96 204 Void resetStats(); 97 #if SAO_CHROMA_LAMBDA98 205 #if SAO_ENCODING_CHOICE 99 206 Void SAOProcess(SAOParam *pcSaoParam, Double dLambda, Double dLambdaChroma, Int depth); 100 207 #else 101 208 Void SAOProcess(SAOParam *pcSaoParam, Double dLambda, Double dLambdaChroma); 102 #endif103 #else104 Void SAOProcess(SAOParam *pcSaoParam, Double dLambda);105 209 #endif 106 210 … … 131 235 Int getMaxNumOffsetsPerPic() {return m_maxNumOffsetsPerPic; } 132 236 }; 133 237 #endif 134 238 //! \} 135 239 -
trunk/source/Lib/TLibEncoder/TEncSbac.cpp
r494 r540 416 416 { 417 417 PartSize eSize = pcCU->getPartitionSize( uiAbsPartIdx ); 418 419 418 if ( pcCU->isIntra( uiAbsPartIdx ) ) 420 419 { … … 1394 1393 { 1395 1394 m_pcBinIf->encodeBin( 1, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) ); 1395 #if HM_CLEANUP_SAO 1396 m_pcBinIf->encodeBinEP( uiCode == 1 ? 0 : 1 ); 1397 #else 1396 1398 m_pcBinIf->encodeBinEP( uiCode <= 4 ? 1 : 0 ); 1399 #endif 1397 1400 } 1398 1401 } … … 1597 1600 } 1598 1601 1602 #if HM_CLEANUP_SAO 1603 Void TEncSbac::codeSAOOffsetParam(Int compIdx, SAOOffset& ctbParam, Bool sliceEnabled) 1604 { 1605 UInt uiSymbol; 1606 if(!sliceEnabled) 1607 { 1608 assert(ctbParam.modeIdc == SAO_MODE_OFF); 1609 return; 1610 } 1611 1612 //type 1613 if(compIdx == SAO_Y || compIdx == SAO_Cb) 1614 { 1615 //sao_type_idx_luma or sao_type_idx_chroma 1616 if(ctbParam.modeIdc == SAO_MODE_OFF) 1617 { 1618 uiSymbol =0; 1619 } 1620 else if(ctbParam.typeIdc == SAO_TYPE_BO) //BO 1621 { 1622 uiSymbol = 1; 1623 } 1624 else 1625 { 1626 assert(ctbParam.typeIdc < SAO_TYPE_START_BO); //EO 1627 uiSymbol = 2; 1628 } 1629 codeSaoTypeIdx(uiSymbol); 1630 } 1631 1632 if(ctbParam.modeIdc == SAO_MODE_NEW) 1633 { 1634 Int numClasses = (ctbParam.typeIdc == SAO_TYPE_BO)?4:NUM_SAO_EO_CLASSES; 1635 Int offset[4]; 1636 Int k=0; 1637 for(Int i=0; i< numClasses; i++) 1638 { 1639 if(ctbParam.typeIdc != SAO_TYPE_BO && i == SAO_CLASS_EO_PLAIN) 1640 { 1641 continue; 1642 } 1643 Int classIdx = (ctbParam.typeIdc == SAO_TYPE_BO)?( (ctbParam.typeAuxInfo+i)% NUM_SAO_BO_CLASSES ):i; 1644 offset[k] = ctbParam.offset[classIdx]; 1645 k++; 1646 } 1647 1648 for(Int i=0; i< 4; i++) 1649 { 1650 codeSaoMaxUvlc((offset[i]<0)?(-offset[i]):(offset[i]), g_saoMaxOffsetQVal[compIdx] ); //sao_offset_abs 1651 } 1652 1653 1654 if(ctbParam.typeIdc == SAO_TYPE_BO) 1655 { 1656 for(Int i=0; i< 4; i++) 1657 { 1658 if(offset[i] != 0) 1659 { 1660 codeSAOSign((offset[i]< 0)?1:0); 1661 } 1662 } 1663 1664 codeSaoUflc(NUM_SAO_BO_CLASSES_LOG2, ctbParam.typeAuxInfo ); //sao_band_position 1665 } 1666 else //EO 1667 { 1668 if(compIdx == SAO_Y || compIdx == SAO_Cb) 1669 { 1670 assert(ctbParam.typeIdc - SAO_TYPE_START_EO >=0); 1671 codeSaoUflc(NUM_SAO_EO_TYPES_LOG2, ctbParam.typeIdc - SAO_TYPE_START_EO ); //sao_eo_class_luma or sao_eo_class_chroma 1672 } 1673 } 1674 1675 } 1676 } 1677 1678 1679 Void TEncSbac::codeSAOBlkParam(SAOBlkParam& saoBlkParam 1680 , Bool* sliceEnabled 1681 , Bool leftMergeAvail 1682 , Bool aboveMergeAvail 1683 , Bool onlyEstMergeInfo // = false 1684 ) 1685 { 1686 1687 Bool isLeftMerge = false; 1688 Bool isAboveMerge= false; 1689 1690 if(leftMergeAvail) 1691 { 1692 isLeftMerge = ((saoBlkParam[SAO_Y].modeIdc == SAO_MODE_MERGE) && (saoBlkParam[SAO_Y].typeIdc == SAO_MERGE_LEFT)); 1693 codeSaoMerge( isLeftMerge?1:0 ); //sao_merge_left_flag 1694 } 1695 1696 if( aboveMergeAvail && !isLeftMerge) 1697 { 1698 isAboveMerge = ((saoBlkParam[SAO_Y].modeIdc == SAO_MODE_MERGE) && (saoBlkParam[SAO_Y].typeIdc == SAO_MERGE_ABOVE)); 1699 codeSaoMerge( isAboveMerge?1:0 ); //sao_merge_left_flag 1700 } 1701 1702 if(onlyEstMergeInfo) 1703 { 1704 return; //only for RDO 1705 } 1706 1707 if(!isLeftMerge && !isAboveMerge) //not merge mode 1708 { 1709 for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++) 1710 { 1711 codeSAOOffsetParam(compIdx, saoBlkParam[compIdx], sliceEnabled[compIdx]); 1712 } 1713 } 1714 } 1715 #endif 1716 1599 1717 //! \} -
trunk/source/Lib/TLibEncoder/TEncSbac.h
r345 r540 103 103 Void codeSAOSign ( UInt uiCode); //<! code SAO offset sign 104 104 Void codeScalingList ( TComScalingList* /*scalingList*/ ){ assert (0); return;}; 105 106 #if HM_CLEANUP_SAO 107 Void codeSAOOffsetParam(Int compIdx, SAOOffset& ctbParam, Bool sliceEnabled); 108 Void codeSAOBlkParam(SAOBlkParam& saoBlkParam 109 , Bool* sliceEnabled 110 , Bool leftMergeAvail 111 , Bool aboveMergeAvail 112 , Bool onlyEstMergeInfo = false 113 ); 114 #endif 105 115 106 116 private: -
trunk/source/Lib/TLibEncoder/TEncSearch.cpp
r494 r540 720 720 Pel* piRefPos; 721 721 Int iRefStride = m_filteredBlock[0][0].getStride(); 722 #if NS_HAD723 m_pcRdCost->setDistParam( pcPatternKey, m_filteredBlock[0][0].getLumaAddr(), iRefStride, 1, m_cDistParam, m_pcEncCfg->getUseHADME(), m_pcEncCfg->getUseNSQT() );724 #else725 722 m_pcRdCost->setDistParam( pcPatternKey, m_filteredBlock[0][0].getLumaAddr(), iRefStride, 1, m_cDistParam, m_pcEncCfg->getUseHADME() ); 726 #endif727 723 728 724 const TComMv* pcMvRefine = (iFrac == 2 ? s_acMvRefineH : s_acMvRefineQ); … … 737 733 piRefPos = m_filteredBlock[ verVal & 3 ][ horVal & 3 ].getLumaAddr(); 738 734 if ( horVal == 2 && ( verVal & 1 ) == 0 ) 735 { 739 736 piRefPos += 1; 737 } 740 738 if ( ( horVal & 1 ) == 0 && verVal == 2 ) 739 { 741 740 piRefPos += iRefStride; 741 } 742 742 cMvTest = pcMvRefine[i]; 743 743 cMvTest += rcMvFrac; … … 774 774 UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()] + 2 - uiFullDepth; 775 775 776 { 777 if( pcCU->getPredictionMode(0) == MODE_INTRA && pcCU->getPartitionSize(0) == SIZE_NxN && uiTrDepth == 0 ) 778 { 779 assert( uiSubdiv ); 780 } 781 else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) 782 { 783 assert( uiSubdiv ); 784 } 785 else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) 786 { 787 assert( !uiSubdiv ); 788 } 789 else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) 790 { 791 assert( !uiSubdiv ); 792 } 793 else 794 { 795 assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ); 796 if( bLuma ) 797 { 798 m_pcEntropyCoder->encodeTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize ); 799 } 776 if( pcCU->getPredictionMode(0) == MODE_INTRA && pcCU->getPartitionSize(0) == SIZE_NxN && uiTrDepth == 0 ) 777 { 778 assert( uiSubdiv ); 779 } 780 else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) 781 { 782 assert( uiSubdiv ); 783 } 784 else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) 785 { 786 assert( !uiSubdiv ); 787 } 788 else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) 789 { 790 assert( !uiSubdiv ); 791 } 792 else 793 { 794 assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ); 795 if( bLuma ) 796 { 797 m_pcEntropyCoder->encodeTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize ); 800 798 } 801 799 } … … 806 804 { 807 805 if( uiTrDepth==0 || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth-1 ) ) 806 { 808 807 m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth ); 808 } 809 809 if( uiTrDepth==0 || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth-1 ) ) 810 { 810 811 m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth ); 812 } 811 813 } 812 814 } … … 822 824 } 823 825 824 { 825 //===== Cbfs ===== 826 if( bLuma ) 827 { 828 m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrMode ); 829 } 826 //===== Cbfs ===== 827 if( bLuma ) 828 { 829 m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrMode ); 830 830 } 831 831 } … … 944 944 } 945 945 } 946 947 946 if( bChroma ) 948 947 { … … 1306 1305 1307 1306 #if RDOQ_CHROMA_LAMBDA 1308 m_pcTrQuant->selectLambda (TEXT_CHROMA);1307 m_pcTrQuant->selectLambda(eText); 1309 1308 #endif 1310 1309 m_pcTrQuant->transformNxN ( pcCU, piResi, uiStride, pcCoeff, … … 1358 1357 1359 1358 //===== update distortion ===== 1360 #if WEIGHTED_CHROMA_DISTORTION1361 1359 ruiDist += m_pcRdCost->getDistPart(g_bitDepthC, piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight, eText ); 1362 #else1363 ruiDist += m_pcRdCost->getDistPart(g_bitDepthC, piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight );1364 #endif1365 1360 } 1366 1361 … … 2539 2534 2540 2535 for( Int j=0; j < numCand; j++) 2541 2542 2536 { 2543 2537 Bool mostProbableModeIncluded = false; … … 3039 3033 pcYuvOrg->getLumaAddr( uiAbsPartIdx ), pcYuvOrg->getStride(), 3040 3034 m_tmpYuvPred .getLumaAddr( uiAbsPartIdx ), m_tmpYuvPred .getStride(), 3041 #if NS_HAD3042 iWidth, iHeight, m_pcEncCfg->getUseHADME(), m_pcEncCfg->getUseNSQT() );3043 #else3044 3035 iWidth, iHeight, m_pcEncCfg->getUseHADME() ); 3045 #endif3046 3036 ruiErr = cDistParam.DistFunc( &cDistParam ); 3047 3037 } … … 3246 3236 3247 3237 UInt uiCostTempL0[MAX_NUM_REF]; 3248 for (Int iNumRef=0; iNumRef < MAX_NUM_REF; iNumRef++) uiCostTempL0[iNumRef] = MAX_UINT; 3238 for (Int iNumRef=0; iNumRef < MAX_NUM_REF; iNumRef++) 3239 { 3240 uiCostTempL0[iNumRef] = MAX_UINT; 3241 } 3249 3242 UInt uiBitsTempL0[MAX_NUM_REF]; 3250 3243 … … 3716 3709 { 3717 3710 uiLastMode = 2; 3718 { 3719 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv( cMvBi[0], ePartSize, uiPartAddr, 0, iPartIdx ); 3720 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdxBi[0], ePartSize, uiPartAddr, 0, iPartIdx ); 3721 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv( cMvBi[1], ePartSize, uiPartAddr, 0, iPartIdx ); 3722 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdxBi[1], ePartSize, uiPartAddr, 0, iPartIdx ); 3723 } 3724 { 3725 TempMv = cMvBi[0] - cMvPredBi[0][iRefIdxBi[0]]; 3726 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd ( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 3727 } 3728 { 3729 TempMv = cMvBi[1] - cMvPredBi[1][iRefIdxBi[1]]; 3730 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd ( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 3731 } 3711 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv( cMvBi[0], ePartSize, uiPartAddr, 0, iPartIdx ); 3712 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdxBi[0], ePartSize, uiPartAddr, 0, iPartIdx ); 3713 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv( cMvBi[1], ePartSize, uiPartAddr, 0, iPartIdx ); 3714 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdxBi[1], ePartSize, uiPartAddr, 0, iPartIdx ); 3715 3716 TempMv = cMvBi[0] - cMvPredBi[0][iRefIdxBi[0]]; 3717 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd ( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 3718 3719 TempMv = cMvBi[1] - cMvPredBi[1][iRefIdxBi[1]]; 3720 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd ( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 3732 3721 3733 3722 pcCU->setInterDirSubParts( 3, uiPartAddr, iPartIdx, pcCU->getDepth(0) ); … … 3743 3732 { 3744 3733 uiLastMode = 0; 3745 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx ); 3746 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx ); 3747 { 3748 TempMv = cMv[0] - cMvPred[0][iRefIdx[0]]; 3749 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd ( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 3750 } 3734 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx ); 3735 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx ); 3736 TempMv = cMv[0] - cMvPred[0][iRefIdx[0]]; 3737 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd ( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 3751 3738 pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) ); 3752 3739 … … 3759 3746 { 3760 3747 uiLastMode = 1; 3761 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx ); 3762 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx ); 3763 { 3764 TempMv = cMv[1] - cMvPred[1][iRefIdx[1]]; 3765 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd ( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 3766 } 3748 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx ); 3749 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx ); 3750 TempMv = cMv[1] - cMvPred[1][iRefIdx[1]]; 3751 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd ( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 3767 3752 pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) ); 3768 3753 … … 3816 3801 pcCU->setMergeIndexSubParts( uiMRGIndex, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 3817 3802 pcCU->setInterDirSubParts ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 3818 { 3819 pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx ); 3820 pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx ); 3821 } 3803 pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx ); 3804 pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx ); 3822 3805 3823 3806 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd ( cMvZero, ePartSize, uiPartAddr, 0, iPartIdx ); … … 3834 3817 pcCU->setMergeFlagSubParts( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 3835 3818 pcCU->setInterDirSubParts ( uiMEInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 3836 { 3837 pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMEMvField[0], ePartSize, uiPartAddr, 0, iPartIdx ); 3838 pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMEMvField[1], ePartSize, uiPartAddr, 0, iPartIdx ); 3839 } 3819 pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMEMvField[0], ePartSize, uiPartAddr, 0, iPartIdx ); 3820 pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMEMvField[1], ePartSize, uiPartAddr, 0, iPartIdx ); 3840 3821 } 3841 3822 } … … 3944 3925 3945 3926 if (iNum == 1) 3927 { 3946 3928 return 0; 3929 } 3947 3930 3948 3931 UInt uiLength = 1; … … 4123 4106 pcOrgYuv->getLumaAddr(uiPartAddr), pcOrgYuv->getStride(), 4124 4107 pcTemplateCand->getLumaAddr(uiPartAddr), pcTemplateCand->getStride(), 4125 #if NS_HAD4126 iSizeX, iSizeY, m_pcEncCfg->getUseHADME(), m_pcEncCfg->getUseNSQT() );4127 #else4128 4108 iSizeX, iSizeY, m_pcEncCfg->getUseHADME() ); 4129 #endif4130 4109 ruiDist = cDistParam.DistFunc( &cDistParam ); 4131 4110 uiCost = ruiDist + m_pcRdCost->getCost( m_auiMVPIdxCost[iMVPIdx][iMVPNum] ); 4132 4111 #else 4133 #if WEIGHTED_CHROMA_DISTORTION4134 4112 uiCost = m_pcRdCost->getDistPart(g_bitDepthY, pcTemplateCand->getLumaAddr(uiPartAddr), pcTemplateCand->getStride(), pcOrgYuv->getLumaAddr(uiPartAddr), pcOrgYuv->getStride(), iSizeX, iSizeY, TEXT_LUMA, DF_SAD ); 4135 #else4136 uiCost = m_pcRdCost->getDistPart(g_bitDepthY, pcTemplateCand->getLumaAddr(uiPartAddr), pcTemplateCand->getStride(), pcOrgYuv->getLumaAddr(uiPartAddr), pcOrgYuv->getStride(), iSizeX, iSizeY, DF_SAD );4137 #endif4138 4113 uiCost = (UInt) m_pcRdCost->calcRdCost( m_auiMVPIdxCost[iMVPIdx][iMVPNum], uiCost, false, DF_SAD ); 4139 4114 #endif … … 4228 4203 m_pcRdCost->getMotionCost( 1, 0 ); 4229 4204 m_pcRdCost->setCostScale ( 1 ); 4230 4231 { 4205 4232 4206 #if REF_IDX_ME_ZEROMV 4233 4234 4235 4236 4237 4238 4239 4240 4207 if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR(pcCU->getLayerId())) //ILR reference pic 4208 { 4209 xPatternSearchFracDIFMv0( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost, bBi ); 4210 } 4211 else //non ILR reference pic 4212 { 4213 xPatternSearchFracDIF( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost, bBi ); 4214 } 4241 4215 #else 4242 xPatternSearchFracDIF( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost 4243 ,bBi 4244 ); 4245 #endif 4246 } 4247 4248 4249 4216 xPatternSearchFracDIF( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost,bBi ); 4217 #endif 4218 4250 4219 m_pcRdCost->setCostScale( 0 ); 4251 4220 rcMv <<= 2; … … 4601 4570 pcYuvPred->copyToPartYuv( rpcYuvRec, 0 ); 4602 4571 4603 #if WEIGHTED_CHROMA_DISTORTION4604 4572 uiDistortion = m_pcRdCost->getDistPart(g_bitDepthY, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(), pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(), uiWidth, uiHeight ) 4605 4573 + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCbAddr(), rpcYuvRec->getCStride(), pcYuvOrg->getCbAddr(), pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1, TEXT_CHROMA_U ) 4606 4574 + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCrAddr(), rpcYuvRec->getCStride(), pcYuvOrg->getCrAddr(), pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1, TEXT_CHROMA_V ); 4607 #else4608 uiDistortion = m_pcRdCost->getDistPart(g_bitDepthY, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(), pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(), uiWidth, uiHeight )4609 + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCbAddr(), rpcYuvRec->getCStride(), pcYuvOrg->getCbAddr(), pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1 )4610 + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCrAddr(), rpcYuvRec->getCStride(), pcYuvOrg->getCrAddr(), pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1 );4611 #endif4612 4575 4613 4576 if( m_bUseSBACRD ) 4577 { 4614 4578 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST]); 4579 } 4615 4580 4616 4581 m_pcEntropyCoder->resetBits(); … … 4628 4593 4629 4594 if( m_bUseSBACRD ) 4595 { 4630 4596 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_TEMP_BEST]); 4597 } 4631 4598 4632 4599 pcCU->setCbfSubParts( 0, 0, 0, 0, pcCU->getDepth( 0 ) ); … … 4799 4766 4800 4767 // update with clipped distortion and cost (qp estimation loop uses unclipped values) 4801 #if WEIGHTED_CHROMA_DISTORTION4802 4768 uiDistortionBest = m_pcRdCost->getDistPart(g_bitDepthY, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(), pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(), uiWidth, uiHeight ) 4803 4769 + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCbAddr(), rpcYuvRec->getCStride(), pcYuvOrg->getCbAddr(), pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1, TEXT_CHROMA_U ) 4804 4770 + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCrAddr(), rpcYuvRec->getCStride(), pcYuvOrg->getCrAddr(), pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1, TEXT_CHROMA_V ); 4805 #else4806 uiDistortionBest = m_pcRdCost->getDistPart(g_bitDepthY, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(), pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(), uiWidth, uiHeight )4807 + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCbAddr(), rpcYuvRec->getCStride(), pcYuvOrg->getCbAddr(), pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1 )4808 + m_pcRdCost->getDistPart(g_bitDepthC, rpcYuvRec->getCrAddr(), rpcYuvRec->getCStride(), pcYuvOrg->getCrAddr(), pcYuvOrg->getCStride(), uiWidth >> 1, uiHeight >> 1 );4809 #endif4810 4771 dCostBest = m_pcRdCost->calcRdCost( uiBitsBest, uiDistortionBest ); 4811 4772 … … 4832 4793 Bool bCheckFull; 4833 4794 if ( SplitFlag && uiDepth == pcCU->getDepth(uiAbsPartIdx) && ( uiLog2TrSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) ) 4795 { 4834 4796 bCheckFull = false; 4797 } 4835 4798 else 4799 { 4836 4800 bCheckFull = ( uiLog2TrSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ); 4801 } 4837 4802 4838 4803 const Bool bCheckSplit = ( uiLog2TrSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ); … … 4932 4897 4933 4898 #if RDOQ_CHROMA_LAMBDA 4934 m_pcTrQuant->selectLambda(TEXT_CHROMA );4899 m_pcTrQuant->selectLambda(TEXT_CHROMA_U); 4935 4900 #endif 4936 4901 … … 4943 4908 curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); 4944 4909 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); 4910 4911 #if RDOQ_CHROMA_LAMBDA 4912 m_pcTrQuant->selectLambda(TEXT_CHROMA_V); 4913 #endif 4914 4945 4915 m_pcTrQuant->transformNxN( pcCU, pcResi->getCrAddr(absTUPartIdxC), pcResi->getCStride(), pcCoeffCurrV, 4946 4916 #if ADAPTIVE_QP_SELECTION … … 4955 4925 m_pcEntropyCoder->resetBits(); 4956 4926 4957 { 4958 m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrMode ); 4959 } 4960 4927 m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrMode ); 4928 4961 4929 m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrY, uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA ); 4962 4930 const UInt uiSingleBitsY = m_pcEntropyCoder->getNumberOfWrittenBits(); … … 4966 4934 if( bCodeChroma ) 4967 4935 { 4968 { 4969 m_pcEntropyCoder->encodeQtCbf ( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrMode ); 4970 } 4936 m_pcEntropyCoder->encodeQtCbf ( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrMode ); 4971 4937 m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrU, uiAbsPartIdx, trWidthC, trHeightC, uiDepth, TEXT_CHROMA_U ); 4972 4938 uiSingleBitsU = m_pcEntropyCoder->getNumberOfWrittenBits() - uiSingleBitsY; 4973 4939 4974 { 4975 m_pcEntropyCoder->encodeQtCbf ( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrMode ); 4976 } 4940 m_pcEntropyCoder->encodeQtCbf ( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrMode ); 4977 4941 m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrV, uiAbsPartIdx, trWidthC, trHeightC, uiDepth, TEXT_CHROMA_V ); 4978 4942 uiSingleBitsV = m_pcEntropyCoder->getNumberOfWrittenBits() - ( uiSingleBitsY + uiSingleBitsU ); … … 5003 4967 assert(scalingListType < 6); 5004 4968 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), pcCoeffCurrY, trWidth, trHeight, scalingListType );//this is for inter mode only 4969 5005 4970 const UInt uiNonzeroDistY = m_pcRdCost->getDistPart(g_bitDepthY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( absTUPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), 5006 4971 pcResi->getLumaAddr( absTUPartIdx ), pcResi->getStride(), trWidth,trHeight ); … … 5059 5024 { 5060 5025 uiDistU = m_pcRdCost->getDistPart(g_bitDepthC, m_pTempPel, trWidthC, pcResi->getCbAddr( absTUPartIdxC ), pcResi->getCStride(), trWidthC, trHeightC 5061 #if WEIGHTED_CHROMA_DISTORTION5062 5026 , TEXT_CHROMA_U 5063 #endif5064 5027 ); // initialized with zero residual destortion 5065 5028 if ( puiZeroDist ) … … 5080 5043 const UInt uiNonzeroDistU = m_pcRdCost->getDistPart(g_bitDepthC, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCbAddr( absTUPartIdxC), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), 5081 5044 pcResi->getCbAddr( absTUPartIdxC), pcResi->getCStride(), trWidthC, trHeightC 5082 #if WEIGHTED_CHROMA_DISTORTION5083 5045 , TEXT_CHROMA_U 5084 #endif5085 5046 ); 5086 5047 … … 5118 5079 { 5119 5080 m_pcEntropyCoder->resetBits(); 5120 m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_U, uiTrMode C);5081 m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_U, uiTrMode ); 5121 5082 const UInt uiNullBitsU = m_pcEntropyCoder->getNumberOfWrittenBits(); 5122 5083 minCostU = m_pcRdCost->calcRdCost( uiNullBitsU, uiDistU ); … … 5134 5095 5135 5096 uiDistV = m_pcRdCost->getDistPart(g_bitDepthC, m_pTempPel, trWidthC, pcResi->getCrAddr( absTUPartIdxC), pcResi->getCStride(), trWidthC, trHeightC 5136 #if WEIGHTED_CHROMA_DISTORTION5137 5097 , TEXT_CHROMA_V 5138 #endif5139 5098 ); // initialized with zero residual destortion 5140 5099 if ( puiZeroDist ) … … 5154 5113 const UInt uiNonzeroDistV = m_pcRdCost->getDistPart(g_bitDepthC, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCrAddr( absTUPartIdxC ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), 5155 5114 pcResi->getCrAddr( absTUPartIdxC ), pcResi->getCStride(), trWidthC, trHeightC 5156 #if WEIGHTED_CHROMA_DISTORTION5157 5115 , TEXT_CHROMA_V 5158 #endif5159 5116 ); 5160 5117 if (pcCU->isLosslessCoded(0)) … … 5191 5148 { 5192 5149 m_pcEntropyCoder->resetBits(); 5193 m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_V, uiTrMode C);5150 m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_V, uiTrMode ); 5194 5151 const UInt uiNullBitsV = m_pcEntropyCoder->getNumberOfWrittenBits(); 5195 5152 minCostV = m_pcRdCost->calcRdCost( uiNullBitsV, uiDistV ); … … 5352 5309 5353 5310 #if RDOQ_CHROMA_LAMBDA 5354 m_pcTrQuant->selectLambda(TEXT_CHROMA );5311 m_pcTrQuant->selectLambda(TEXT_CHROMA_U); 5355 5312 #endif 5356 5313 … … 5362 5319 curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); 5363 5320 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); 5321 #if RDOQ_CHROMA_LAMBDA 5322 m_pcTrQuant->selectLambda(TEXT_CHROMA_V); 5323 #endif 5364 5324 m_pcTrQuant->transformNxN( pcCU, pcResi->getCrAddr(absTUPartIdxC), pcResi->getCStride(), pcCoeffCurrV, 5365 5325 #if ADAPTIVE_QP_SELECTION … … 5391 5351 uiNonzeroDistU = m_pcRdCost->getDistPart(g_bitDepthC, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCbAddr( absTUPartIdxC), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), 5392 5352 pcResi->getCbAddr( absTUPartIdxC), pcResi->getCStride(), trWidthC, trHeightC 5393 #if WEIGHTED_CHROMA_DISTORTION5394 5353 , TEXT_CHROMA_U 5395 #endif5396 5354 ); 5397 5355 … … 5435 5393 uiNonzeroDistV = m_pcRdCost->getDistPart(g_bitDepthC, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCrAddr( absTUPartIdxC ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), 5436 5394 pcResi->getCrAddr( absTUPartIdxC ), pcResi->getCStride(), trWidthC, trHeightC 5437 #if WEIGHTED_CHROMA_DISTORTION5438 5395 , TEXT_CHROMA_V 5439 #endif5440 5396 ); 5441 5397 … … 5474 5430 m_pcEntropyCoder->resetBits(); 5475 5431 5476 { 5477 if( uiLog2TrSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) 5478 { 5479 m_pcEntropyCoder->encodeTransformSubdivFlag( 0, 5 - uiLog2TrSize ); 5480 } 5481 } 5482 5483 { 5484 if( bCodeChroma ) 5485 { 5486 m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrMode ); 5487 m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrMode ); 5488 } 5489 5490 m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrMode ); 5491 } 5432 if( uiLog2TrSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) 5433 { 5434 m_pcEntropyCoder->encodeTransformSubdivFlag( 0, 5 - uiLog2TrSize ); 5435 } 5436 5437 if( bCodeChroma ) 5438 { 5439 m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrMode ); 5440 m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrMode ); 5441 } 5442 5443 m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrMode ); 5492 5444 5493 5445 m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrY, uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA ); … … 5546 5498 m_pcEntropyCoder->resetBits(); 5547 5499 5548 { 5549 xEncodeResidualQT( pcCU, uiAbsPartIdx, uiDepth, true, TEXT_LUMA ); 5550 xEncodeResidualQT( pcCU, uiAbsPartIdx, uiDepth, false, TEXT_LUMA ); 5551 xEncodeResidualQT( pcCU, uiAbsPartIdx, uiDepth, false, TEXT_CHROMA_U ); 5552 xEncodeResidualQT( pcCU, uiAbsPartIdx, uiDepth, false, TEXT_CHROMA_V ); 5553 } 5554 5500 xEncodeResidualQT( pcCU, uiAbsPartIdx, uiDepth, true, TEXT_LUMA ); 5501 xEncodeResidualQT( pcCU, uiAbsPartIdx, uiDepth, false, TEXT_LUMA ); 5502 xEncodeResidualQT( pcCU, uiAbsPartIdx, uiDepth, false, TEXT_CHROMA_U ); 5503 xEncodeResidualQT( pcCU, uiAbsPartIdx, uiDepth, false, TEXT_CHROMA_V ); 5504 5555 5505 uiSubdivBits = m_pcEntropyCoder->getNumberOfWrittenBits(); 5556 5506 dSubdivCost = m_pcRdCost->calcRdCost( uiSubdivBits, uiSubdivDist ); … … 5602 5552 const UInt uiLog2TrSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth]+2; 5603 5553 5604 { 5605 if( bSubdivAndCbf && uiLog2TrSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() && uiLog2TrSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) 5606 { 5607 m_pcEntropyCoder->encodeTransformSubdivFlag( bSubdiv, 5 - uiLog2TrSize ); 5608 } 5609 } 5610 5611 { 5612 assert( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA ); 5554 if( bSubdivAndCbf && uiLog2TrSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() && uiLog2TrSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) 5555 { 5556 m_pcEntropyCoder->encodeTransformSubdivFlag( bSubdiv, 5 - uiLog2TrSize ); 5557 } 5558 5559 assert( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA ); 5613 5560 if( bSubdivAndCbf ) 5614 5561 { … … 5631 5578 } 5632 5579 } 5633 }5634 5580 5635 5581 if( !bSubdiv ) … … 5655 5601 if( bSubdivAndCbf ) 5656 5602 { 5657 { 5658 m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrMode ); 5659 } 5603 m_pcEntropyCoder->encodeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrMode ); 5660 5604 } 5661 5605 else … … 5725 5669 if( bCodeChroma ) 5726 5670 { 5727 { 5728 m_pcQTTempTComYuv[uiQTTempAccessLayer].copyPartToPartChroma( pcResi, uiAbsPartIdx, 1 << uiLog2TrSizeC, 1 << uiLog2TrSizeC ); 5729 } 5671 m_pcQTTempTComYuv[uiQTTempAccessLayer].copyPartToPartChroma( pcResi, uiAbsPartIdx, 1 << uiLog2TrSizeC, 1 << uiLog2TrSizeC ); 5730 5672 } 5731 5673 } … … 5847 5789 m_pcEntropyCoder->encodePartSize( pcCU, 0, pcCU->getDepth(0), true ); 5848 5790 m_pcEntropyCoder->encodePredInfo( pcCU, 0, true ); 5849 5850 5791 Bool bDummy = false; 5851 5792 m_pcEntropyCoder->encodeCoeff ( pcCU, 0, pcCU->getDepth(0), pcCU->getWidth(0), pcCU->getHeight(0), bDummy ); -
trunk/source/Lib/TLibEncoder/TEncSearch.h
r494 r540 194 194 UInt uiPreCalcDistC ); 195 195 196 196 197 /// encoder estimation - inter prediction (non-skip) 197 198 Void predInterSearch ( TComDataCU* pcCU, -
trunk/source/Lib/TLibEncoder/TEncSlice.cpp
r494 r540 295 295 dQP += pdQPs[ rpcSlice->getPOC() ]; 296 296 } 297 #if !RATE_CONTROL_LAMBDA_DOMAIN298 if ( m_pcCfg->getUseRateCtrl())299 {300 dQP = m_pcRateCtrl->getFrameQP(rpcSlice->isReferenced(), rpcSlice->getPOC());301 }302 #endif303 297 // ------------------------------------------------------------------------------------------------------------------ 304 298 // Lambda computation … … 386 380 // store lambda 387 381 m_pcRdCost ->setLambda( dLambda ); 388 #if WEIGHTED_CHROMA_DISTORTION389 382 // for RDO 390 383 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma. 391 Double weight = 1.0;384 Double weight[2] = { 1.0, 1.0 }; 392 385 Int qpc; 393 386 Int chromaQPOffset; … … 395 388 chromaQPOffset = rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb(); 396 389 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 397 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset398 m_pcRdCost->setCbDistortionWeight(weight );390 weight[0] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 391 m_pcRdCost->setCbDistortionWeight(weight[0]); 399 392 400 393 chromaQPOffset = rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr(); 401 394 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 402 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 395 weight[1] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 396 m_pcRdCost->setCrDistortionWeight(weight[1]); 397 403 398 #if JCTVC_M0259_LAMBDAREFINEMENT 404 399 if( rpcSlice->getLayerId() > 0 && m_ppcTEncTop[layerId]->getNumActiveRefLayers() && m_pcCfg->getGOPSize() >= 8 && rpcSlice->isIntra() == false && depth == 0 ) 405 400 { 406 401 dLambda *= 1.1; 407 weight *= 1.15; 408 } 409 #endif 410 m_pcRdCost->setCrDistortionWeight(weight); 411 #endif 412 402 weight[1] *= 1.15; 403 weight[0] *= 1.15; 404 405 m_pcRdCost ->setLambda( dLambda ); 406 m_pcRdCost->setCbDistortionWeight(weight[0]); 407 m_pcRdCost->setCrDistortionWeight(weight[1]); 408 } 409 #endif 410 411 const Double lambdaArray[3] = {dLambda, (dLambda / weight[0]), (dLambda / weight[1])}; 412 413 413 #if RDOQ_CHROMA_LAMBDA 414 414 // for RDOQ 415 m_pcTrQuant->setLambda ( dLambda, dLambda / weight);415 m_pcTrQuant->setLambdas( lambdaArray ); 416 416 #else 417 417 m_pcTrQuant->setLambda( dLambda ); 418 418 #endif 419 419 420 #if SAO_CHROMA_LAMBDA421 420 // For SAO 422 rpcSlice ->setLambda( dLambda, dLambda / weight ); 423 #else 424 rpcSlice ->setLambda( dLambda ); 425 #endif 421 rpcSlice->setLambdas( lambdaArray ); 426 422 427 423 #if HB_LAMBDA_FOR_LDC … … 430 426 431 427 #if SVC_EXTENSION 432 if( m_pcCfg->getLayerId() > 0)428 if( m_pcCfg->getLayerId() > 0 && m_pcCfg->getNumActiveRefLayers() > 0 ) 433 429 { 434 430 eSliceType=B_SLICE; … … 500 496 501 497 pcPic->setTLayer( m_pcCfg->getGOPEntry(iGOPid).m_temporalId ); 502 503 498 if(eSliceType==I_SLICE) 504 499 { … … 517 512 rpcSlice->setSliceSegmentArgument ( m_pcCfg->getSliceSegmentArgument() ); 518 513 rpcSlice->setMaxNumMergeCand ( m_pcCfg->getMaxNumMergeCand() ); 514 #if HIGHER_LAYER_IRAP_SKIP_FLAG 515 if (m_pcCfg->getSkipPictureAtArcSwitch() && m_pcCfg->getAdaptiveResolutionChange() > 0 && rpcSlice->getLayerId() == 1 && rpcSlice->getPOC() == m_pcCfg->getAdaptiveResolutionChange()) 516 { 517 rpcSlice->setMaxNumMergeCand ( 1 ); 518 } 519 #endif 519 520 xStoreWPparam( pPPS->getUseWP(), pPPS->getWPBiPred() ); 520 521 … … 546 547 } 547 548 548 #if RATE_CONTROL_LAMBDA_DOMAIN549 549 Void TEncSlice::resetQP( TComPic* pic, Int sliceQP, Double lambda ) 550 550 { … … 555 555 slice->setSliceQpBase ( sliceQP ); 556 556 m_pcRdCost ->setLambda( lambda ); 557 #if WEIGHTED_CHROMA_DISTORTION558 557 // for RDO 559 558 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma. 560 Double weight ;559 Double weight[2] = { 1.0, 1.0 }; 561 560 Int qpc; 562 561 Int chromaQPOffset; … … 564 563 chromaQPOffset = slice->getPPS()->getChromaCbQpOffset() + slice->getSliceQpDeltaCb(); 565 564 qpc = Clip3( 0, 57, sliceQP + chromaQPOffset); 566 weight = pow( 2.0, (sliceQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset567 m_pcRdCost->setCbDistortionWeight(weight );565 weight[0] = pow( 2.0, (sliceQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 566 m_pcRdCost->setCbDistortionWeight(weight[0]); 568 567 569 568 chromaQPOffset = slice->getPPS()->getChromaCrQpOffset() + slice->getSliceQpDeltaCr(); 570 569 qpc = Clip3( 0, 57, sliceQP + chromaQPOffset); 571 weight = pow( 2.0, (sliceQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 572 m_pcRdCost->setCrDistortionWeight(weight); 573 #endif 570 weight[1] = pow( 2.0, (sliceQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 571 m_pcRdCost->setCrDistortionWeight(weight[1]); 572 573 const Double lambdaArray[3] = {lambda, (lambda / weight[0]), (lambda / weight[1])}; 574 574 575 575 #if RDOQ_CHROMA_LAMBDA 576 576 // for RDOQ 577 m_pcTrQuant->setLambda ( lambda, lambda / weight);577 m_pcTrQuant->setLambdas( lambdaArray ); 578 578 #else 579 579 m_pcTrQuant->setLambda( lambda ); 580 580 #endif 581 581 582 #if SAO_CHROMA_LAMBDA583 582 // For SAO 584 slice ->setLambda( lambda, lambda / weight ); 585 #else 586 slice ->setLambda( lambda ); 587 #endif 583 slice->setLambdas( lambdaArray ); 588 584 } 589 #else590 /**591 - lambda re-computation based on rate control QP592 */593 Void TEncSlice::xLamdaRecalculation(Int changeQP, Int idGOP, Int depth, SliceType eSliceType, TComSPS* pcSPS, TComSlice* pcSlice)594 {595 Int qp;596 Double recalQP= (Double)changeQP;597 Double origQP = (Double)recalQP;598 Double lambda;599 600 // pre-compute lambda and QP values for all possible QP candidates601 for ( Int deltqQpIdx = 0; deltqQpIdx < 2 * m_pcCfg->getDeltaQpRD() + 1; deltqQpIdx++ )602 {603 // compute QP value604 recalQP = origQP + ((deltqQpIdx+1)>>1)*(deltqQpIdx%2 ? -1 : 1);605 606 // compute lambda value607 Int NumberBFrames = ( m_pcCfg->getGOPSize() - 1 );608 Int SHIFT_QP = 12;609 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)NumberBFrames );610 #if FULL_NBIT611 Int bitdepth_luma_qp_scale = 6 * (g_bitDepth - 8);612 #else613 Int bitdepth_luma_qp_scale = 0;614 #endif615 Double qp_temp = (Double) recalQP + bitdepth_luma_qp_scale - SHIFT_QP;616 #if FULL_NBIT617 Double qp_temp_orig = (Double) recalQP - SHIFT_QP;618 #endif619 // Case #1: I or P-slices (key-frame)620 Double dQPFactor = m_pcCfg->getGOPEntry(idGOP).m_QPFactor;621 if ( eSliceType==I_SLICE )622 {623 dQPFactor=0.57*dLambda_scale;624 }625 lambda = dQPFactor*pow( 2.0, qp_temp/3.0 );626 627 if ( depth>0 )628 {629 #if FULL_NBIT630 lambda *= Clip3( 2.00, 4.00, (qp_temp_orig / 6.0) ); // (j == B_SLICE && p_cur_frm->layer != 0 )631 #else632 lambda *= Clip3( 2.00, 4.00, (qp_temp / 6.0) ); // (j == B_SLICE && p_cur_frm->layer != 0 )633 #endif634 }635 636 // if hadamard is used in ME process637 if ( !m_pcCfg->getUseHADME() )638 {639 lambda *= 0.95;640 }641 642 #if REPN_FORMAT_IN_VPS643 qp = max( -pcSlice->getQpBDOffsetY(), min( MAX_QP, (Int) floor( recalQP + 0.5 ) ) );644 #else645 qp = max( -pcSPS->getQpBDOffsetY(), min( MAX_QP, (Int) floor( recalQP + 0.5 ) ) );646 #endif647 648 m_pdRdPicLambda[deltqQpIdx] = lambda;649 m_pdRdPicQp [deltqQpIdx] = recalQP;650 m_piRdPicQp [deltqQpIdx] = qp;651 }652 653 // obtain dQP = 0 case654 lambda = m_pdRdPicLambda[0];655 recalQP = m_pdRdPicQp [0];656 qp = m_piRdPicQp [0];657 658 if( pcSlice->getSliceType( ) != I_SLICE )659 {660 lambda *= m_pcCfg->getLambdaModifier( depth );661 }662 663 // store lambda664 m_pcRdCost ->setLambda( lambda );665 #if WEIGHTED_CHROMA_DISTORTION666 // for RDO667 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma.668 Double weight = 1.0;669 Int qpc;670 Int chromaQPOffset;671 672 chromaQPOffset = pcSlice->getPPS()->getChromaCbQpOffset() + pcSlice->getSliceQpDeltaCb();673 qpc = Clip3( 0, 57, qp + chromaQPOffset);674 weight = pow( 2.0, (qp-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset675 m_pcRdCost->setCbDistortionWeight(weight);676 677 chromaQPOffset = pcSlice->getPPS()->getChromaCrQpOffset() + pcSlice->getSliceQpDeltaCr();678 qpc = Clip3( 0, 57, qp + chromaQPOffset);679 weight = pow( 2.0, (qp-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset680 m_pcRdCost->setCrDistortionWeight(weight);681 #endif682 683 #if RDOQ_CHROMA_LAMBDA684 // for RDOQ685 m_pcTrQuant->setLambda( lambda, lambda / weight );686 #else687 m_pcTrQuant->setLambda( lambda );688 #endif689 690 #if SAO_CHROMA_LAMBDA691 // For SAO692 pcSlice ->setLambda( lambda, lambda / weight );693 #else694 pcSlice ->setLambda( lambda );695 #endif696 }697 #endif698 585 // ==================================================================================================================== 699 586 // Public member functions … … 735 622 } 736 623 737 #if RATE_CONTROL_LAMBDA_DOMAIN738 624 if ( m_pcCfg->getUseRateCtrl() ) 739 625 { … … 741 627 assert(0); 742 628 } 743 #endif744 629 745 630 TComSlice* pcSlice = rpcPic->getSlice(getSliceIdx()); … … 773 658 #endif 774 659 m_pcRdCost ->setLambda ( m_pdRdPicLambda[uiQpIdx] ); 775 #if WEIGHTED_CHROMA_DISTORTION776 660 // for RDO 777 661 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma. 778 662 Int iQP = m_piRdPicQp [uiQpIdx]; 779 Double weight = 1.0;663 Double weight[2] = { 1.0, 1.0 }; 780 664 Int qpc; 781 665 Int chromaQPOffset; … … 783 667 chromaQPOffset = pcSlice->getPPS()->getChromaCbQpOffset() + pcSlice->getSliceQpDeltaCb(); 784 668 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 785 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset786 m_pcRdCost->setCbDistortionWeight(weight );669 weight[0] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 670 m_pcRdCost->setCbDistortionWeight(weight[0]); 787 671 788 672 chromaQPOffset = pcSlice->getPPS()->getChromaCrQpOffset() + pcSlice->getSliceQpDeltaCr(); 789 673 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 790 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset791 m_pcRdCost->setCrDistortionWeight(weight );792 #endif 793 674 weight[1] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 675 m_pcRdCost->setCrDistortionWeight(weight[1]); 676 677 const Double lambdaArray[3] = {m_pdRdPicLambda[uiQpIdx], (m_pdRdPicLambda[uiQpIdx] / weight[0]), (m_pdRdPicLambda[uiQpIdx] / weight[1])}; 794 678 #if RDOQ_CHROMA_LAMBDA 795 679 // for RDOQ 796 m_pcTrQuant ->setLambda( m_pdRdPicLambda[uiQpIdx], m_pdRdPicLambda[uiQpIdx] / weight);680 m_pcTrQuant->setLambdas( lambdaArray ); 797 681 #else 798 682 m_pcTrQuant ->setLambda ( m_pdRdPicLambda[uiQpIdx] ); 799 683 #endif 800 #if SAO_CHROMA_LAMBDA801 684 // For SAO 802 pcSlice ->setLambda ( m_pdRdPicLambda[uiQpIdx], m_pdRdPicLambda[uiQpIdx] / weight ); 803 #else 804 pcSlice ->setLambda ( m_pdRdPicLambda[uiQpIdx] ); 805 #endif 685 pcSlice->setLambdas( lambdaArray ); 806 686 807 687 // try compress … … 830 710 #endif 831 711 m_pcRdCost ->setLambda ( m_pdRdPicLambda[uiQpIdxBest] ); 832 #if WEIGHTED_CHROMA_DISTORTION833 712 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma. 834 713 Int iQP = m_piRdPicQp [uiQpIdxBest]; 835 Double weight = 1.0;714 Double weight[2] = { 1.0, 1.0 }; 836 715 Int qpc; 837 716 Int chromaQPOffset; … … 839 718 chromaQPOffset = pcSlice->getPPS()->getChromaCbQpOffset() + pcSlice->getSliceQpDeltaCb(); 840 719 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 841 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset842 m_pcRdCost->setCbDistortionWeight(weight );720 weight[0] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 721 m_pcRdCost->setCbDistortionWeight(weight[0]); 843 722 844 723 chromaQPOffset = pcSlice->getPPS()->getChromaCrQpOffset() + pcSlice->getSliceQpDeltaCr(); 845 724 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 846 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset847 m_pcRdCost->setCrDistortionWeight(weight );848 #endif 849 725 weight[1] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 726 m_pcRdCost->setCrDistortionWeight(weight[1]); 727 728 const Double lambdaArray[3] = {m_pdRdPicLambda[uiQpIdxBest], (m_pdRdPicLambda[uiQpIdxBest] / weight[0]), (m_pdRdPicLambda[uiQpIdxBest] / weight[1])}; 850 729 #if RDOQ_CHROMA_LAMBDA 851 730 // for RDOQ 852 m_pcTrQuant ->setLambda( m_pdRdPicLambda[uiQpIdxBest], m_pdRdPicLambda[uiQpIdxBest] / weight);731 m_pcTrQuant->setLambdas( lambdaArray ); 853 732 #else 854 733 m_pcTrQuant ->setLambda ( m_pdRdPicLambda[uiQpIdxBest] ); 855 734 #endif 856 #if SAO_CHROMA_LAMBDA857 735 // For SAO 858 pcSlice ->setLambda ( m_pdRdPicLambda[uiQpIdxBest], m_pdRdPicLambda[uiQpIdxBest] / weight ); 859 #else 860 pcSlice ->setLambda ( m_pdRdPicLambda[uiQpIdxBest] ); 861 #endif 736 pcSlice->setLambdas( lambdaArray ); 862 737 } 863 738 864 739 /** \param rpcPic picture class 865 740 */ 866 #if RATE_CONTROL_INTRA867 741 Void TEncSlice::calCostSliceI(TComPic*& rpcPic) 868 742 { … … 903 777 m_pcRateCtrl->getRCPic()->setTotalIntraCost(iSumHadSlice); 904 778 } 905 #endif906 779 907 780 Void TEncSlice::compressSlice( TComPic*& rpcPic ) … … 1031 904 UInt uiTileStartLCU = 0; 1032 905 UInt uiTileLCUX = 0; 1033 1034 906 Bool depSliceSegmentsEnabled = pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag(); 1035 907 uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU()); … … 1080 952 pcCU->initCU( rpcPic, uiCUAddr ); 1081 953 1082 #if !RATE_CONTROL_LAMBDA_DOMAIN1083 if(m_pcCfg->getUseRateCtrl())1084 {1085 if(m_pcRateCtrl->calculateUnitQP())1086 {1087 xLamdaRecalculation(m_pcRateCtrl->getUnitQP(), m_pcRateCtrl->getGOPId(), pcSlice->getDepth(), pcSlice->getSliceType(), pcSlice->getSPS(), pcSlice );1088 }1089 }1090 #endif1091 954 // inherit from TR if necessary, select substream to use. 1092 955 if( m_pcCfg->getUseSBACRD() ) … … 1163 1026 ((TEncBinCABAC*)m_pcRDGoOnSbacCoder->getEncBinIf())->setBinCountingEnableFlag(true); 1164 1027 1165 #if RATE_CONTROL_LAMBDA_DOMAIN1166 1028 Double oldLambda = m_pcRdCost->getLambda(); 1167 1029 if ( m_pcCfg->getUseRateCtrl() ) … … 1171 1033 Double bpp = -1.0; 1172 1034 1173 #if M0036_RC_IMPROVEMENT1174 1035 if ( ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE && m_pcCfg->getForceIntraQP() ) || !m_pcCfg->getLCULevelRC() ) 1175 #else1176 if ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE || !m_pcCfg->getLCULevelRC() )1177 #endif1178 1036 { 1179 1037 estQP = pcSlice->getSliceQp(); … … 1181 1039 else 1182 1040 { 1183 #if RATE_CONTROL_INTRA1184 1041 bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBpp(pcSlice->getSliceType()); 1185 1042 if ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE) … … 1192 1049 estQP = m_pcRateCtrl->getRCPic()->getLCUEstQP ( estLambda, pcSlice->getSliceQp() ); 1193 1050 } 1194 #else1195 bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBpp();1196 estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambda( bpp );1197 estQP = m_pcRateCtrl->getRCPic()->getLCUEstQP ( estLambda, pcSlice->getSliceQp() );1198 #endif1199 1051 1200 1052 #if REPN_FORMAT_IN_VPS … … 1205 1057 1206 1058 m_pcRdCost->setLambda(estLambda); 1207 #if M0036_RC_IMPROVEMENT1208 1059 #if RDOQ_CHROMA_LAMBDA 1209 1060 // set lambda for RDOQ 1210 1061 Double weight=m_pcRdCost->getChromaWeight(); 1211 m_pcTrQuant->setLambda( estLambda, estLambda / weight ); 1062 const Double lambdaArray[3] = { estLambda, (estLambda / weight), (estLambda / weight) }; 1063 m_pcTrQuant->setLambdas( lambdaArray ); 1212 1064 #else 1213 1065 m_pcTrQuant->setLambda( estLambda ); 1214 #endif1215 1066 #endif 1216 1067 } … … 1219 1070 pcCU->getSlice()->setSliceQpBase( estQP ); 1220 1071 } 1221 #endif1222 1072 1223 1073 // run CU encoder 1224 1074 m_pcCuEncoder->compressCU( pcCU ); 1225 1226 #if !TICKET_1090_FIX1227 #if RATE_CONTROL_LAMBDA_DOMAIN1228 if ( m_pcCfg->getUseRateCtrl() )1229 {1230 #if !M0036_RC_IMPROVEMENT1231 UInt SAD = m_pcCuEncoder->getLCUPredictionSAD();1232 #if REPN_FORMAT_IN_VPS1233 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );1234 Int width = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->>getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );1235 #else1236 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );1237 Int width = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );1238 #endif1239 Double MAD = (Double)SAD / (Double)(height * width);1240 MAD = MAD * MAD;1241 ( m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr) ).m_MAD = MAD;1242 #endif1243 1244 Int actualQP = g_RCInvalidQPValue;1245 Double actualLambda = m_pcRdCost->getLambda();1246 Int actualBits = pcCU->getTotalBits();1247 Int numberOfEffectivePixels = 0;1248 for ( Int idx = 0; idx < rpcPic->getNumPartInCU(); idx++ )1249 {1250 if ( pcCU->getPredictionMode( idx ) != MODE_NONE && ( !pcCU->isSkipped( idx ) ) )1251 {1252 numberOfEffectivePixels = numberOfEffectivePixels + 16;1253 break;1254 }1255 }1256 1257 if ( numberOfEffectivePixels == 0 )1258 {1259 actualQP = g_RCInvalidQPValue;1260 }1261 else1262 {1263 actualQP = pcCU->getQP( 0 );1264 }1265 m_pcRdCost->setLambda(oldLambda);1266 #if RATE_CONTROL_INTRA1267 m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda,1268 pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() );1269 #else1270 m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, m_pcCfg->getLCULevelRC() );1271 #endif1272 }1273 #endif1274 #endif1275 1075 1276 1076 // restore entropy coder to an initial stage … … 1306 1106 } 1307 1107 1308 #if TICKET_1090_FIX1309 #if RATE_CONTROL_LAMBDA_DOMAIN1310 1108 if ( m_pcCfg->getUseRateCtrl() ) 1311 1109 { 1312 #if !M0036_RC_IMPROVEMENT1313 UInt SAD = m_pcCuEncoder->getLCUPredictionSAD();1314 #if REPN_FORMAT_IN_VPS1315 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );1316 Int width = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );1317 #else1318 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );1319 Int width = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );1320 #endif1321 Double MAD = (Double)SAD / (Double)(height * width);1322 MAD = MAD * MAD;1323 ( m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr) ).m_MAD = MAD;1324 #endif1325 1110 1326 1111 Int actualQP = g_RCInvalidQPValue; … … 1347 1132 m_pcRdCost->setLambda(oldLambda); 1348 1133 1349 #if RATE_CONTROL_INTRA1350 1134 m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, 1351 1135 pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() ); 1352 #else 1353 m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, m_pcCfg->getLCULevelRC() ); 1354 #endif 1355 } 1356 #endif 1357 #endif 1136 } 1358 1137 } 1359 1138 // other case: encodeCU is not called … … 1377 1156 m_dPicRdCost += pcCU->getTotalCost(); 1378 1157 m_uiPicDist += pcCU->getTotalDistortion(); 1379 #if !RATE_CONTROL_LAMBDA_DOMAIN1380 if(m_pcCfg->getUseRateCtrl())1381 {1382 m_pcRateCtrl->updateLCUData(pcCU, pcCU->getTotalBits(), pcCU->getQP(0));1383 m_pcRateCtrl->updataRCUnitStatus();1384 }1385 #endif1386 1158 } 1387 1159 if ((pcSlice->getPPS()->getNumSubstreams() > 1) && !depSliceSegmentsEnabled) … … 1398 1170 } 1399 1171 xRestoreWPparam( pcSlice ); 1400 #if !RATE_CONTROL_LAMBDA_DOMAIN1401 if(m_pcCfg->getUseRateCtrl())1402 {1403 m_pcRateCtrl->updateFrameData(m_uiPicTotalBits);1404 }1405 #endif1406 1172 } 1407 1173 … … 1603 1369 1604 1370 TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr ); 1371 #if HM_CLEANUP_SAO 1372 if ( pcSlice->getSPS()->getUseSAO() ) 1373 { 1374 if (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) 1375 { 1376 SAOBlkParam& saoblkParam = (rpcPic->getPicSym()->getSAOBlkParam())[uiCUAddr]; 1377 Bool sliceEnabled[NUM_SAO_COMPONENTS]; 1378 sliceEnabled[SAO_Y] = pcSlice->getSaoEnabledFlag(); 1379 sliceEnabled[SAO_Cb]= sliceEnabled[SAO_Cr]= pcSlice->getSaoEnabledFlagChroma(); 1380 1381 Bool leftMergeAvail = false; 1382 Bool aboveMergeAvail= false; 1383 //merge left condition 1384 Int rx = (uiCUAddr % uiWidthInLCUs); 1385 if(rx > 0) 1386 { 1387 leftMergeAvail = rpcPic->getSAOMergeAvailability(uiCUAddr, uiCUAddr-1); 1388 } 1389 1390 //merge up condition 1391 Int ry = (uiCUAddr / uiWidthInLCUs); 1392 if(ry > 0) 1393 { 1394 aboveMergeAvail = rpcPic->getSAOMergeAvailability(uiCUAddr, uiCUAddr-uiWidthInLCUs); 1395 } 1396 1397 m_pcEntropyCoder->encodeSAOBlkParam(saoblkParam,sliceEnabled, leftMergeAvail, aboveMergeAvail); 1398 } 1399 } 1400 #else 1605 1401 if ( pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) ) 1606 1402 { … … 1685 1481 } 1686 1482 } 1483 #endif 1484 1687 1485 #if ENC_DEC_TRACE 1688 1486 g_bJustDoIt = g_bEncDecTraceEnable; -
trunk/source/Lib/TLibEncoder/TEncSlice.h
r494 r540 131 131 #endif 132 132 133 #if RATE_CONTROL_LAMBDA_DOMAIN134 133 Void resetQP ( TComPic* pic, Int sliceQP, Double lambda ); 135 #else136 Void xLamdaRecalculation ( Int changeQP, Int idGOP, Int depth, SliceType eSliceType, TComSPS* pcSPS, TComSlice* pcSlice);137 #endif138 134 // compress and encode slice 139 135 Void precompressSlice ( TComPic*& rpcPic ); ///< precompress slice for multi-loop opt. 140 136 Void compressSlice ( TComPic*& rpcPic ); ///< analysis stage of slice 141 #if RATE_CONTROL_INTRA142 137 Void calCostSliceI ( TComPic*& rpcPic ); 143 #endif144 138 Void encodeSlice ( TComPic*& rpcPic, TComOutputBitstream* pcSubstreams ); 145 139 -
trunk/source/Lib/TLibEncoder/TEncTop.cpp
r494 r540 92 92 m_pocAdjustmentValue = 0; 93 93 #endif 94 #if NO_CLRAS_OUTPUT_FLAG 95 m_noClrasOutputFlag = false; 96 m_layerInitializedFlag = false; 97 m_firstPicInLayerDecodedFlag = false; 98 m_noOutputOfPriorPicsFlags = false; 99 #endif 94 100 #endif //SVC_EXTENSION 95 101 } … … 123 129 if (m_bUseSAO) 124 130 { 131 #if HM_CLEANUP_SAO 132 #if AUXILIARY_PICTURES 133 m_cEncSAO.create( getSourceWidth(), getSourceHeight(), m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 134 #else 135 m_cEncSAO.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 136 #endif 137 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 138 m_cEncSAO.createEncData(getSaoLcuBoundary()); 139 #else 140 m_cEncSAO.createEncData(); 141 #endif 142 #else 125 143 m_cEncSAO.setSaoLcuBoundary(getSaoLcuBoundary()); 126 144 m_cEncSAO.setSaoLcuBasedOptimization(getSaoLcuBasedOptimization()); … … 128 146 m_cEncSAO.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight ); 129 147 m_cEncSAO.createEncBuffer(); 148 #endif 130 149 } 131 150 #if ADAPTIVE_QP_SELECTION … … 137 156 m_cLoopFilter. create( g_uiMaxCUDepth ); 138 157 139 #if RATE_CONTROL_LAMBDA_DOMAIN140 158 if ( m_RCEnableRateControl ) 141 159 { … … 143 161 g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList ); 144 162 } 145 #else146 m_cRateCtrl.create(getIntraPeriod(), getGOPSize(), getFrameRate(), getTargetBitrate(), getQP(), getNumLCUInUnit(), getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight);147 #endif148 163 // if SBAC-based RD optimization is used 149 164 if( m_bUseSBACRD ) … … 244 259 if (m_cSPS.getUseSAO()) 245 260 { 261 #if HM_CLEANUP_SAO 262 m_cEncSAO.destroyEncData(); 263 m_cEncSAO.destroy(); 264 #else 246 265 m_cEncSAO.destroy(); 247 266 m_cEncSAO.destroyEncBuffer(); 267 #endif 248 268 } 249 269 m_cLoopFilter. destroy(); … … 395 415 { 396 416 // compress GOP 397 #if RATE_CONTROL_LAMBDA_DOMAIN398 417 #if !RC_SHVC_HARMONIZATION 399 418 if ( m_RCEnableRateControl ) … … 402 421 } 403 422 #endif 404 #endif405 423 406 424 // compress GOP 407 425 m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false); 408 426 409 #if RATE_CONTROL_LAMBDA_DOMAIN410 427 #if !RC_SHVC_HARMONIZATION 411 428 if ( m_RCEnableRateControl ) … … 413 430 m_cRateCtrl.destroyRCGOP(); 414 431 } 415 #endif416 432 #endif 417 433 … … 457 473 } 458 474 459 #if RATE_CONTROL_LAMBDA_DOMAIN460 475 if ( m_RCEnableRateControl ) 461 476 { 462 477 m_cRateCtrl.initRCGOP( m_iNumPicRcvd ); 463 478 } 464 #endif465 479 466 480 // compress GOP … … 468 482 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false); 469 483 470 #if RATE_CONTROL_LAMBDA_DOMAIN471 484 if ( m_RCEnableRateControl ) 472 485 { 473 486 m_cRateCtrl.destroyRCGOP(); 474 487 } 475 #endif476 488 477 489 iNumEncoded = m_iNumPicRcvd; … … 513 525 TComPic *pcTopField; 514 526 xGetNewPicBuffer( pcTopField ); 527 #if !HM_CLEANUP_SAO 515 528 pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO); 529 #endif 516 530 pcTopField->setReconMark (false); 517 531 … … 534 548 Pel * pcTopFieldU = pcTopField->getPicYuvOrg()->getCbAddr(); 535 549 Pel * pcTopFieldV = pcTopField->getPicYuvOrg()->getCrAddr(); 536 550 537 551 // compute image characteristics 538 552 if ( getUseAdaptiveQP() ) 539 553 { 540 554 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcTopField ) ); 541 } 542 555 } 556 543 557 /* -- Defield -- */ 544 558 … … 554 568 TComPic* pcBottomField; 555 569 xGetNewPicBuffer( pcBottomField ); 570 #if !HM_CLEANUP_SAO 556 571 pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO); 572 #endif 557 573 pcBottomField->setReconMark (false); 558 574 … … 575 591 Pel * pcBottomFieldU = pcBottomField->getPicYuvOrg()->getCbAddr(); 576 592 Pel * pcBottomFieldV = pcBottomField->getPicYuvOrg()->getCrAddr(); 577 578 // Compute image characteristics593 594 // compute image characteristics 579 595 if ( getUseAdaptiveQP() ) 580 596 { 581 597 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcBottomField ) ); 582 } 583 598 } 599 584 600 /* -- Defield -- */ 585 601 … … 636 652 TComPic *pcTopField; 637 653 xGetNewPicBuffer( pcTopField ); 654 #if !HM_CLEANUP_SAO 638 655 pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO); 656 #endif 639 657 pcTopField->setReconMark (false); 640 658 … … 688 706 TComPic* pcBottomField; 689 707 xGetNewPicBuffer( pcBottomField ); 708 #if !HM_CLEANUP_SAO 690 709 pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO); 710 #endif 691 711 pcBottomField->setReconMark (false); 692 712 693 TComPicYuv* rpcPicYuvRec = new TComPicYuv;713 TComPicYuv* rpcPicYuvRec; 694 714 if ( rcListPicYuvRecOut.size() == (UInt)m_iGOPSize ) 695 715 { … … 698 718 else 699 719 { 720 rpcPicYuvRec = new TComPicYuv; 700 721 rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 701 722 } … … 791 812 for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ ) 792 813 { 814 #if O0098_SCALED_REF_LAYER_ID 815 const Window scalEL = getSPS()->getScaledRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i)); 816 #else 793 817 const Window scalEL = getSPS()->getScaledRefLayerWindow(i); 818 #endif 794 819 Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); 795 820 … … 842 867 for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ ) 843 868 { 869 #if O0098_SCALED_REF_LAYER_ID 870 const Window scalEL = getSPS()->getScaledRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i)); 871 #else 844 872 const Window scalEL = getSPS()->getScaledRefLayerWindow(i); 873 #endif 845 874 Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); 846 875 … … 883 912 #endif 884 913 } 885 914 #if !HM_CLEANUP_SAO 886 915 if (getUseSAO()) 887 916 { 888 917 rpcPic->getPicSym()->allocSaoParam(&m_cEncSAO); 889 918 } 919 #endif 890 920 m_cListPic.pushBack( rpcPic ); 891 921 } … … 912 942 for(Int i = 0; i < m_cSPS.getNumScaledRefLayerOffsets(); i++) 913 943 { 944 #if O0098_SCALED_REF_LAYER_ID 945 m_cSPS.setScaledRefLayerId(i, m_scaledRefLayerId[i]); 946 #endif 914 947 m_cSPS.getScaledRefLayerWindow(i) = m_scaledRefLayerWindow[i]; 915 948 } … … 1063 1096 Void TEncTop::xInitPPS() 1064 1097 { 1065 #if IL_SL_SIGNALLING_N03711066 m_cPPS.setLayerId( m_layerId);1098 #if SCALINGLIST_INFERRING 1099 m_cPPS.setLayerId( m_layerId ); 1067 1100 #endif 1068 1101 … … 1072 1105 #if REPN_FORMAT_IN_VPS 1073 1106 Int lowestQP; 1107 #if O0096_REP_FORMAT_INDEX 1108 if( m_layerId == 0 ) 1109 { 1110 lowestQP = - m_cSPS.getQpBDOffsetY(); 1111 } 1112 else 1113 { 1114 lowestQP = - (m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_cSPS.getUpdateRepFormatFlag() ? m_cSPS.getUpdateRepFormatIndex() : m_layerId ) )->getBitDepthVpsLuma() - 8) * 6; 1115 } 1116 #else 1074 1117 if( m_layerId == 0 || m_cSPS.getUpdateRepFormatFlag() ) 1075 1118 { … … 1080 1123 lowestQP = - (m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) )->getBitDepthVpsLuma() - 8) * 6; 1081 1124 } 1125 #endif 1082 1126 #else 1083 1127 Int lowestQP = - m_cSPS.getQpBDOffsetY(); … … 1119 1163 } 1120 1164 1121 #if RATE_CONTROL_LAMBDA_DOMAIN1122 1165 if ( m_RCEnableRateControl ) 1123 1166 { … … 1126 1169 m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) ); 1127 1170 } 1128 #endif1129 1171 1130 1172 m_cPPS.setChromaCbQpOffset( m_chromaCbQpOffset ); … … 1209 1251 #if POC_RESET_FLAG 1210 1252 m_cPPS.setNumExtraSliceHeaderBits( 2 ); 1253 #endif 1254 #if O0149_CROSS_LAYER_BLA_FLAG 1255 if (m_crossLayerBLAFlag) 1256 { 1257 m_cPPS.setNumExtraSliceHeaderBits( 3 ); 1258 } 1211 1259 #endif 1212 1260 } … … 1607 1655 Void TEncTop::xInitILRP() 1608 1656 { 1657 #if O0096_REP_FORMAT_INDEX 1658 RepFormat *repFormat = m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_cSPS.getUpdateRepFormatFlag() ? m_cSPS.getUpdateRepFormatIndex() : m_layerId ) ); 1659 #else 1609 1660 RepFormat *repFormat = m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) ); 1661 #endif 1610 1662 Int bitDepthY,bitDepthC,picWidth,picHeight; 1611 1663 1664 #if O0096_REP_FORMAT_INDEX 1665 bitDepthY = repFormat->getBitDepthVpsLuma(); 1666 bitDepthC = repFormat->getBitDepthVpsChroma(); 1667 picWidth = repFormat->getPicWidthVpsInLumaSamples(); 1668 picHeight = repFormat->getPicHeightVpsInLumaSamples(); 1669 #else 1612 1670 if( m_cSPS.getUpdateRepFormatFlag() ) 1613 1671 { … … 1624 1682 picHeight = repFormat->getPicHeightVpsInLumaSamples(); 1625 1683 } 1684 #endif 1626 1685 1627 1686 if(m_layerId > 0) … … 1661 1720 } 1662 1721 #endif 1722 1723 #if O0098_SCALED_REF_LAYER_ID 1724 Window& TEncTop::getScaledRefLayerWindowForLayer(Int layerId) 1725 { 1726 static Window win; 1727 1728 for (Int i = 0; i < m_numScaledRefLayerOffsets; i++) 1729 { 1730 if (layerId == m_scaledRefLayerId[i]) 1731 { 1732 return m_scaledRefLayerWindow[i]; 1733 } 1734 } 1735 1736 win.resetWindow(); // scaled reference layer offsets are inferred to be zero when not present 1737 return win; 1738 } 1739 #endif 1740 1663 1741 #endif //SVC_EXTENSION 1664 1742 //! \} -
trunk/source/Lib/TLibEncoder/TEncTop.h
r494 r540 83 83 // encoder search 84 84 TEncSearch m_cSearch; ///< encoder search class 85 TEncEntropy* m_pcEntropyCoder; ///< entropy encoder85 //TEncEntropy* m_pcEntropyCoder; ///< entropy encoder 86 86 TEncCavlc* m_pcCavlcCoder; ///< CAVLC encoder 87 87 // coding tool … … 141 141 #endif 142 142 UInt m_numScaledRefLayerOffsets; 143 #if O0098_SCALED_REF_LAYER_ID 144 UInt m_scaledRefLayerId[MAX_LAYERS]; 145 #endif 143 146 Window m_scaledRefLayerWindow[MAX_LAYERS]; 144 147 #if POC_RESET_FLAG 145 148 Int m_pocAdjustmentValue; 149 #endif 150 #if NO_CLRAS_OUTPUT_FLAG 151 Bool m_noClrasOutputFlag; 152 Bool m_layerInitializedFlag; 153 Bool m_firstPicInLayerDecodedFlag; 154 Bool m_noOutputOfPriorPicsFlags; 146 155 #endif 147 156 #endif //SVC_EXTENSION … … 209 218 Void setNumScaledRefLayerOffsets(Int x) { m_numScaledRefLayerOffsets = x; } 210 219 UInt getNumScaledRefLayerOffsets() { return m_numScaledRefLayerOffsets; } 220 #if O0098_SCALED_REF_LAYER_ID 221 Void setScaledRefLayerId(Int x, UInt id) { m_scaledRefLayerId[x] = id; } 222 UInt getScaledRefLayerId(Int x) { return m_scaledRefLayerId[x]; } 223 Window& getScaledRefLayerWindowForLayer(Int layerId); 224 #endif 211 225 Window& getScaledRefLayerWindow(Int x) { return m_scaledRefLayerWindow[x]; } 212 226 #endif //SVC_EXTENSION … … 242 256 Void setPocAdjustmentValue(Int x) { m_pocAdjustmentValue = x; } 243 257 #endif 258 #if NO_CLRAS_OUTPUT_FLAG 259 Int getNoClrasOutputFlag() { return m_noClrasOutputFlag;} 260 Void setNoClrasOutputFlag(Bool x) { m_noClrasOutputFlag = x; } 261 Int getLayerInitializedFlag() { return m_layerInitializedFlag;} 262 Void setLayerInitializedFlag(Bool x) { m_layerInitializedFlag = x; } 263 Int getFirstPicInLayerDecodedFlag() { return m_firstPicInLayerDecodedFlag;} 264 Void setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x; } 265 Int getNoOutputOfPriorPicsFlags() { return m_noOutputOfPriorPicsFlags;} 266 Void setNoOutputOfPriorPicsFlags(Bool x) { m_noOutputOfPriorPicsFlags = x; } 267 #endif 244 268 #else //SVC_EXTENSION 245 269 Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
Note: See TracChangeset for help on using the changeset viewer.