Ticket #1450: reduceHMMemory.patch
File reduceHMMemory.patch, 27.6 KB (added by karlsharman, 8 years ago) |
---|
-
source/Lib/TLibCommon/TComDataCU.cpp
95 95 96 96 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 97 97 { 98 m_apcCUColocated[i] = NULL;98 //m_apcCUColocated[i] = NULL; 99 99 m_apiMVPIdx[i] = NULL; 100 100 m_apiMVPNum[i] = NULL; 101 101 } … … 205 205 m_pCtuAbove = NULL; 206 206 m_pCtuLeft = NULL; 207 207 208 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)209 {210 m_apcCUColocated[i] = NULL;211 }208 //for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 209 //{ 210 // m_apcCUColocated[i] = NULL; 211 //} 212 212 } 213 213 214 214 Void TComDataCU::destroy() … … 373 373 m_pCtuLeft = NULL; 374 374 375 375 376 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)377 {378 m_apcCUColocated[i] = NULL;379 }376 //for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 377 //{ 378 // m_apcCUColocated[i] = NULL; 379 //} 380 380 381 381 } 382 382 … … 503 503 m_pCtuAboveRight = NULL; 504 504 505 505 506 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)507 {508 m_apcCUColocated[i] = NULL;509 }506 //for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 507 //{ 508 // m_apcCUColocated[i] = NULL; 509 //} 510 510 511 511 UInt frameWidthInCtus = pcPic->getFrameWidthInCtus(); 512 512 if ( m_ctuRsAddr % frameWidthInCtus ) … … 529 529 m_pCtuAboveRight = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus + 1 ); 530 530 } 531 531 532 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)533 {534 const RefPicList rpl=RefPicList(i);535 if ( getSlice()->getNumRefIdx( rpl ) > 0 )536 {537 m_apcCUColocated[rpl] = getSlice()->getRefPic( rpl, 0)->getCtu( m_ctuRsAddr );538 }539 }532 //for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 533 //{ 534 // const RefPicList rpl=RefPicList(i); 535 // if ( getSlice()->getNumRefIdx( rpl ) > 0 ) 536 // { 537 // m_apcCUColocated[rpl] = getSlice()->getRefPic( rpl, 0)->getCtu( m_ctuRsAddr ); 538 // } 539 //} 540 540 } 541 541 542 542 … … 707 707 m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); 708 708 m_pCtuAboveRight = pcCU->getCtuAboveRight(); 709 709 710 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)711 {712 m_apcCUColocated[i] = pcCU->getCUColocated(RefPicList(i));713 }710 //for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 711 //{ 712 // m_apcCUColocated[i] = pcCU->getCUColocated(RefPicList(i)); 713 //} 714 714 } 715 715 716 716 Void TComDataCU::setOutsideCUPart( UInt uiAbsPartIdx, UInt uiDepth ) … … 782 782 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 783 783 { 784 784 const RefPicList rpl=RefPicList(i); 785 m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl);785 // m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl); 786 786 m_apiMVPIdx[rpl]=pcCU->getMVPIdx(rpl) + uiPart; 787 787 m_apiMVPNum[rpl]=pcCU->getMVPNum(rpl) + uiPart; 788 788 } … … 828 828 m_pCtuAbove = pcCU->getCtuAbove(); 829 829 m_pCtuLeft = pcCU->getCtuLeft(); 830 830 831 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)832 {833 m_apcCUColocated[i] = pcCU->getCUColocated(RefPicList(i));834 }831 //for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 832 //{ 833 // m_apcCUColocated[i] = pcCU->getCUColocated(RefPicList(i)); 834 //} 835 835 836 836 m_skipFlag = pcCU->getSkipFlag () + uiAbsPartIdx; 837 837 … … 914 914 const RefPicList rpl=RefPicList(i); 915 915 memcpy( m_apiMVPIdx[rpl] + uiOffset, pcCU->getMVPIdx(rpl), iSizeInUchar ); 916 916 memcpy( m_apiMVPNum[rpl] + uiOffset, pcCU->getMVPNum(rpl), iSizeInUchar ); 917 m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl);917 // m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl); 918 918 } 919 919 920 920 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) … … 2993 2993 2994 2994 // use coldir. 2995 2995 const TComPic * const pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); 2996 const TComDataCU * const pColCtu = pColPic->getCtu( ctuRsAddr ); 2997 if(pColCtu->getPic()==0 || pColCtu->getPartitionSize(partUnitIdx)==NUMBER_OF_PART_SIZES) 2996 const TComPicSym::DPBPerCtuData * const pColDpbCtu = &(pColPic->getPicSym()->getDPBPerCtuData(ctuRsAddr)); 2997 const TComSlice * const pColSlice = pColDpbCtu->getSlice(); 2998 if(/*pColCtu->getPic()==0 || */pColDpbCtu->getPartitionSize(partUnitIdx)==NUMBER_OF_PART_SIZES) 2998 2999 { 2999 3000 return false; 3000 3001 } 3001 3002 3002 if (!pCol Ctu->isInter(absPartAddr))3003 if (!pColDpbCtu->isInter(absPartAddr)) 3003 3004 { 3004 3005 return false; 3005 3006 } 3006 3007 3007 3008 RefPicList eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag()); 3008 Int iColRefIdx = pCol Ctu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr);3009 Int iColRefIdx = pColDpbCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr); 3009 3010 3010 3011 if (iColRefIdx < 0 ) 3011 3012 { 3012 3013 eColRefPicList = RefPicList(1 - eColRefPicList); 3013 iColRefIdx = pCol Ctu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr);3014 iColRefIdx = pColDpbCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr); 3014 3015 3015 3016 if (iColRefIdx < 0 ) 3016 3017 { … … 3019 3020 } 3020 3021 3021 3022 const Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, refIdx)->getIsLongTerm(); 3022 const Bool bIsColRefLongTerm = pCol Ctu->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx);3023 const Bool bIsColRefLongTerm = pColSlice->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx); 3023 3024 3024 3025 if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) 3025 3026 { … … 3027 3028 } 3028 3029 3029 3030 // Scale the vector. 3030 const TComMv &cColMv = pCol Ctu->getCUMvField(eColRefPicList)->getMv(absPartAddr);3031 const TComMv &cColMv = pColDpbCtu->getCUMvField(eColRefPicList)->getMv(absPartAddr); 3031 3032 if ( bIsCurrRefLongTerm /*|| bIsColRefLongTerm*/ ) 3032 3033 { 3033 3034 rcMv = cColMv; … … 3035 3036 else 3036 3037 { 3037 3038 const Int currPOC = m_pcSlice->getPOC(); 3038 const Int colPOC = pCol Ctu->getSlice()->getPOC();3039 const Int colRefPOC = pCol Ctu->getSlice()->getRefPOC(eColRefPicList, iColRefIdx);3039 const Int colPOC = pColSlice->getPOC(); 3040 const Int colRefPOC = pColSlice->getRefPOC(eColRefPicList, iColRefIdx); 3040 3041 const Int currRefPOC = m_pcSlice->getRefPic(eRefPicList, refIdx)->getPOC(); 3041 3042 const Int scale = xGetDistScaleFactor(currPOC, currRefPOC, colPOC, colRefPOC); 3042 3043 if ( scale == 4096 ) … … 3087 3088 3088 3089 Void TComDataCU::compressMV() 3089 3090 { 3090 Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize; 3091 if (scaleFactor > 0) 3091 const Int scaleFactor = std::max<Int>(1,4 * AMVP_DECIMATION_FACTOR / m_unitSize); 3092 TComPicSym &picSym=*(getPic()->getPicSym()); 3093 TComPicSym::DPBPerCtuData &dpbForCtu=picSym.getDPBPerCtuData(getCtuRsAddr()); 3094 3095 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 3092 3096 { 3093 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 3094 { 3095 m_acCUMvField[i].compress(m_pePredMode, scaleFactor); 3096 } 3097 dpbForCtu.m_CUMvField[i].compress(dpbForCtu.m_pePredMode, m_pePredMode, scaleFactor,m_acCUMvField[i]); 3098 memcpy(dpbForCtu.m_pePartSize, m_pePartSize, sizeof(*m_pePartSize)*m_uiNumPartition); 3099 dpbForCtu.m_pSlice = getSlice(); 3097 3100 } 3098 3101 } 3099 3102 -
source/Lib/TLibCommon/TComDataCU.h
118 118 TComDataCU* m_pCtuAboveRight; ///< pointer of above-right CTU. 119 119 TComDataCU* m_pCtuAbove; ///< pointer of above CTU. 120 120 TComDataCU* m_pCtuLeft; ///< pointer of left CTU 121 TComDataCU* m_apcCUColocated[NUM_REF_PIC_LIST_01]; ///< pointer of temporally colocated CU's for both directions121 //TComDataCU* m_apcCUColocated[NUM_REF_PIC_LIST_01]; ///< pointer of temporally colocated CU's for both directions 122 122 TComMvField m_cMvFieldA; ///< motion vector of position A 123 123 TComMvField m_cMvFieldB; ///< motion vector of position B 124 124 TComMvField m_cMvFieldC; ///< motion vector of position C … … 392 392 TComDataCU* getCtuAbove ( ) { return m_pCtuAbove; } 393 393 TComDataCU* getCtuAboveLeft ( ) { return m_pCtuAboveLeft; } 394 394 TComDataCU* getCtuAboveRight ( ) { return m_pCtuAboveRight; } 395 TComDataCU* getCUColocated ( RefPicList eRefPicList ) { return m_apcCUColocated[eRefPicList]; }395 //TComDataCU* getCUColocated ( RefPicList eRefPicList ) { return m_apcCUColocated[eRefPicList]; } 396 396 Bool CUIsFromSameSlice ( const TComDataCU *pCU /* Can be NULL */ ) const { return ( pCU!=NULL && pCU->getSlice()->getSliceCurStartCtuTsAddr() == getSlice()->getSliceCurStartCtuTsAddr() ); } 397 397 Bool CUIsFromSameTile ( const TComDataCU *pCU /* Can be NULL */ ) const; 398 398 Bool CUIsFromSameSliceAndTile ( const TComDataCU *pCU /* Can be NULL */ ) const; -
source/Lib/TLibCommon/TComMotionInfo.cpp
327 327 * \param pePredMode Pointer to prediction modes 328 328 * \param scale Factor by which to subsample motion information 329 329 */ 330 Void TComCUMvField::compress(SChar * pePredMode, Int scale)330 Void TComCUMvField::compress(SChar *pePredMode, const SChar* pePredModeSource, const Int scale, const TComCUMvField &source) 331 331 { 332 Int N = scale * scale; 333 assert( N > 0 && N <= m_uiNumPartition); 332 const Int numSubpartsWithIdenticalMotion = scale * scale; 333 assert( numSubpartsWithIdenticalMotion > 0 && numSubpartsWithIdenticalMotion <= m_uiNumPartition); 334 assert(source.m_uiNumPartition == m_uiNumPartition); 334 335 335 for ( Int uiPartIdx = 0; uiPartIdx < m_uiNumPartition; uiPartIdx += N)336 for ( Int partIdx = 0; partIdx < m_uiNumPartition; partIdx += numSubpartsWithIdenticalMotion ) 336 337 { 337 338 TComMv cMv(0,0); 338 339 Int iRefIdx = 0; 339 340 340 cMv = m_pcMv[ uiPartIdx ];341 PredMode predMode = static_cast<PredMode>( pePredMode [ uiPartIdx ] );342 iRefIdx = m_piRefIdx[ uiPartIdx ];343 for ( Int i = 0; i < N; i++ )341 cMv = source.m_pcMv[ partIdx ]; 342 PredMode predMode = static_cast<PredMode>( pePredModeSource[ partIdx ] ); 343 iRefIdx = source.m_piRefIdx[ partIdx ]; 344 for ( Int i = 0; i < numSubpartsWithIdenticalMotion; i++ ) 344 345 { 345 m_pcMv[ uiPartIdx + i ] = cMv;346 pePredMode[ uiPartIdx + i ] = predMode;347 m_piRefIdx[ uiPartIdx + i ] = iRefIdx;346 m_pcMv[ partIdx + i ] = cMv; 347 pePredMode[ partIdx + i ] = predMode; 348 m_piRefIdx[ partIdx + i ] = iRefIdx; 348 349 } 349 350 } 350 351 } -
source/Lib/TLibCommon/TComMotionInfo.h
152 152 m_piRefIdx = src->m_piRefIdx + offset; 153 153 } 154 154 155 Void compress(SChar * pePredMode, Int scale);155 Void compress(SChar *pePredMode, const SChar* pePredModeSource, const Int scale, const TComCUMvField &source); 156 156 }; 157 157 158 158 //! \} -
source/Lib/TLibCommon/TComPic.cpp
67 67 destroy(); 68 68 } 69 69 70 Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool b IsVirtual)70 Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bCreateEncoderSourcePicYuv, const Bool bCreateForImmediateReconstruction ) 71 71 { 72 72 destroy(); 73 73 … … 78 78 const UInt uiMaxCuHeight = sps.getMaxCUHeight(); 79 79 const UInt uiMaxDepth = sps.getMaxTotalCUDepth(); 80 80 81 m_picSym.create( sps, pps, uiMaxDepth );82 if ( !bIsVirtual)81 m_picSym.create( sps, pps, uiMaxDepth, bCreateForImmediateReconstruction ); 82 if (bCreateEncoderSourcePicYuv) 83 83 { 84 84 m_apcPicYuv[PIC_YUV_ORG ] = new TComPicYuv; m_apcPicYuv[PIC_YUV_ORG ]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true ); 85 85 m_apcPicYuv[PIC_YUV_TRUE_ORG] = new TComPicYuv; m_apcPicYuv[PIC_YUV_TRUE_ORG]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true ); 86 86 } 87 m_apcPicYuv[PIC_YUV_REC] = new TComPicYuv; m_apcPicYuv[PIC_YUV_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true ); 87 if (bCreateForImmediateReconstruction) 88 { 89 m_apcPicYuv[PIC_YUV_REC] = new TComPicYuv; m_apcPicYuv[PIC_YUV_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true ); 90 } 88 91 89 92 // there are no SEI messages associated with this picture initially 90 93 if (m_SEIs.size() > 0) … … 94 97 m_bUsedByCurr = false; 95 98 } 96 99 100 Void TComPic::prepareForEncoderSourcePicYuv() 101 { 102 const TComSPS &sps=m_picSym.getSPS(); 103 104 const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc(); 105 const Int iWidth = sps.getPicWidthInLumaSamples(); 106 const Int iHeight = sps.getPicHeightInLumaSamples(); 107 const UInt uiMaxCuWidth = sps.getMaxCUWidth(); 108 const UInt uiMaxCuHeight = sps.getMaxCUHeight(); 109 const UInt uiMaxDepth = sps.getMaxTotalCUDepth(); 110 111 if (m_apcPicYuv[PIC_YUV_ORG ]==NULL) 112 { 113 m_apcPicYuv[PIC_YUV_ORG ] = new TComPicYuv; m_apcPicYuv[PIC_YUV_ORG ]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true ); 114 } 115 if (m_apcPicYuv[PIC_YUV_TRUE_ORG ]==NULL) 116 { 117 m_apcPicYuv[PIC_YUV_TRUE_ORG] = new TComPicYuv; m_apcPicYuv[PIC_YUV_TRUE_ORG]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true ); 118 } 119 } 120 121 Void TComPic::prepareForReconstruction() 122 { 123 if (m_apcPicYuv[PIC_YUV_REC] == NULL) 124 { 125 const TComSPS &sps=m_picSym.getSPS(); 126 const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc(); 127 const Int iWidth = sps.getPicWidthInLumaSamples(); 128 const Int iHeight = sps.getPicHeightInLumaSamples(); 129 const UInt uiMaxCuWidth = sps.getMaxCUWidth(); 130 const UInt uiMaxCuHeight = sps.getMaxCUHeight(); 131 const UInt uiMaxDepth = sps.getMaxTotalCUDepth(); 132 133 m_apcPicYuv[PIC_YUV_REC] = new TComPicYuv; m_apcPicYuv[PIC_YUV_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true ); 134 } 135 136 // mark it should be extended 137 m_apcPicYuv[PIC_YUV_REC]->setBorderExtension(false); 138 139 m_picSym.prepareForReconstruction(); 140 } 141 142 Void TComPic::releaseReconstructionIntermediateData() 143 { 144 #if KJS_DEBUG 145 double mem_before=get_mem_usage(); 146 #endif 147 m_picSym.releaseReconstructionIntermediateData(); 148 #if KJS_DEBUG 149 printf("%-60s: %6.1f MBytes total, %6.1f MBytes\n", "At releaseReconstructionIntermediateData", get_mem_usage()/1024, (get_mem_usage()-mem_before)/1024); 150 #endif 151 } 152 153 Void TComPic::releaseEncoderSourceImageData() 154 { 155 #if KJS_DEBUG 156 double mem_before=get_mem_usage(); 157 #endif 158 if (m_apcPicYuv[PIC_YUV_ORG ]) 159 { 160 m_apcPicYuv[PIC_YUV_ORG]->destroy(); 161 delete m_apcPicYuv[PIC_YUV_ORG]; 162 m_apcPicYuv[PIC_YUV_ORG] = NULL; 163 } 164 if (m_apcPicYuv[PIC_YUV_TRUE_ORG ]) 165 { 166 m_apcPicYuv[PIC_YUV_TRUE_ORG]->destroy(); 167 delete m_apcPicYuv[PIC_YUV_TRUE_ORG]; 168 m_apcPicYuv[PIC_YUV_TRUE_ORG] = NULL; 169 } 170 #if KJS_DEBUG 171 printf("%-60s: %6.1f MBytes total, %6.1f MBytes\n", "At releaseEncoderSourceImageData", get_mem_usage()/1024, (get_mem_usage()-mem_before)/1024); 172 #endif 173 } 174 175 Void TComPic::releaseAllReconstructionData() 176 { 177 178 #if KJS_DEBUG 179 double mem_before=get_mem_usage(); 180 #endif 181 182 if (m_apcPicYuv[PIC_YUV_REC ]) 183 { 184 m_apcPicYuv[PIC_YUV_REC]->destroy(); 185 delete m_apcPicYuv[PIC_YUV_REC]; 186 m_apcPicYuv[PIC_YUV_REC] = NULL; 187 } 188 m_picSym.releaseAllReconstructionData(); 189 #if KJS_DEBUG 190 printf("%-60s: %6.1f MBytes total, %6.1f MBytes\n", "At releaseAllReconstructionData", get_mem_usage()/1024, (get_mem_usage()-mem_before)/1024); 191 #endif 192 } 193 194 97 195 Void TComPic::destroy() 98 196 { 99 197 m_picSym.destroy(); -
source/Lib/TLibCommon/TComPic.h
85 85 TComPic(); 86 86 virtual ~TComPic(); 87 87 88 Void create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual /*= false*/ ); 88 Void create( const TComSPS &sps, const TComPPS &pps, const Bool bCreateEncoderSourcePicYuv, const Bool bCreateForImmediateReconstruction ); 89 Void prepareForEncoderSourcePicYuv(); 90 Void prepareForReconstruction(); 91 Void releaseReconstructionIntermediateData(); 92 Void releaseAllReconstructionData(); 93 Void releaseEncoderSourceImageData(); 89 94 90 95 virtual Void destroy(); 91 96 -
source/Lib/TLibCommon/TComPicSym.cpp
63 63 ,m_ctuTsToRsAddrMap(NULL) 64 64 ,m_puiTileIdxMap(NULL) 65 65 ,m_ctuRsToTsAddrMap(NULL) 66 ,m_dpbPerCtuData(NULL) 66 67 ,m_saoBlkParams(NULL) 67 68 #if ADAPTIVE_QP_SELECTION 68 69 ,m_pParentARLBuffer(NULL) … … 76 77 } 77 78 78 79 79 Void TComPicSym::create ( const TComSPS &sps, const TComPPS &pps, UInt uiMaxDepth )80 Void TComPicSym::create ( const TComSPS &sps, const TComPPS &pps, UInt uiMaxDepth, const Bool bAllocateCtuArray ) 80 81 { 81 82 destroy(); 82 83 83 84 m_sps = sps; 84 85 m_pps = pps; 85 86 86 const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc();87 //const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc(); 87 88 const Int iPicWidth = sps.getPicWidthInLumaSamples(); 88 89 const Int iPicHeight = sps.getPicHeightInLumaSamples(); 89 90 const UInt uiMaxCuWidth = sps.getMaxCUWidth(); … … 102 103 m_frameHeightInCtus = ( iPicHeight%uiMaxCuHeight ) ? iPicHeight/uiMaxCuHeight + 1 : iPicHeight/uiMaxCuHeight; 103 104 104 105 m_numCtusInFrame = m_frameWidthInCtus * m_frameHeightInCtus; 105 m_pictureCtuArray = new TComDataCU*[m_numCtusInFrame];106 m_pictureCtuArray = NULL; 106 107 107 108 clearSliceBuffer(); 108 109 allocateNewSlice(); … … 110 111 #if ADAPTIVE_QP_SELECTION 111 112 if (m_pParentARLBuffer == NULL) 112 113 { 113 114 m_pParentARLBuffer = new TCoeff[uiMaxCuWidth*uiMaxCuHeight*MAX_NUM_COMPONENT]; 114 115 } 115 116 #endif 116 117 117 for (UInt i=0; i<m_numCtusInFrame ; i++)118 if (bAllocateCtuArray) 118 119 { 119 m_pictureCtuArray[i] = new TComDataCU; 120 m_pictureCtuArray[i]->create( chromaFormatIDC, m_numPartitionsInCtu, uiMaxCuWidth, uiMaxCuHeight, false, uiMaxCuWidth >> m_uhTotalDepth 121 #if ADAPTIVE_QP_SELECTION 122 , m_pParentARLBuffer 123 #endif 124 ); 120 prepareForReconstruction(); 125 121 } 126 122 127 123 m_ctuTsToRsAddrMap = new UInt[m_numCtusInFrame+1]; … … 142 138 143 139 } 144 140 145 Void TComPicSym:: destroy()141 Void TComPicSym::prepareForReconstruction() 146 142 { 147 clearSliceBuffer(); 143 const ChromaFormat chromaFormatIDC = m_sps.getChromaFormatIdc(); 144 const UInt uiMaxCuWidth = m_sps.getMaxCUWidth(); 145 const UInt uiMaxCuHeight = m_sps.getMaxCUHeight(); 146 if (m_pictureCtuArray == NULL) 147 { 148 m_pictureCtuArray = new TComDataCU*[m_numCtusInFrame]; 149 150 for (UInt i=0; i<m_numCtusInFrame ; i++ ) 151 { 152 m_pictureCtuArray[i] = new TComDataCU; 153 m_pictureCtuArray[i]->create( chromaFormatIDC, m_numPartitionsInCtu, uiMaxCuWidth, uiMaxCuHeight, false, uiMaxCuWidth >> m_uhTotalDepth 154 #if ADAPTIVE_QP_SELECTION 155 , m_pParentARLBuffer 156 #endif 157 ); 158 } 159 } 160 if (m_dpbPerCtuData == NULL) 161 { 162 m_dpbPerCtuData = new DPBPerCtuData[m_numCtusInFrame]; 163 for(UInt i=0; i<m_numCtusInFrame; i++) 164 { 165 for(Int j=0; j<NUM_REF_PIC_LIST_01; j++) 166 { 167 m_dpbPerCtuData[i].m_CUMvField[j].create( m_numPartitionsInCtu ); 168 } 169 m_dpbPerCtuData[i].m_pePredMode = new SChar[m_numPartitionsInCtu]; 170 m_dpbPerCtuData[i].m_pePartSize = new SChar[m_numPartitionsInCtu]; 171 m_dpbPerCtuData[i].m_pSlice=NULL; 172 } 173 } 174 } 148 175 176 Void TComPicSym::releaseReconstructionIntermediateData() 177 { 149 178 if (m_pictureCtuArray) 150 179 { 151 180 for (Int i = 0; i < m_numCtusInFrame; i++) … … 160 189 delete [] m_pictureCtuArray; 161 190 m_pictureCtuArray = NULL; 162 191 } 192 } 193 194 Void TComPicSym::releaseAllReconstructionData() 195 { 196 releaseReconstructionIntermediateData(); 197 198 if (m_dpbPerCtuData != NULL) 199 { 200 for(UInt i=0; i<m_numCtusInFrame; i++) 201 { 202 for(Int j=0; j<NUM_REF_PIC_LIST_01; j++) 203 { 204 m_dpbPerCtuData[i].m_CUMvField[j].destroy(); 205 } 206 delete [] m_dpbPerCtuData[i].m_pePredMode; 207 delete [] m_dpbPerCtuData[i].m_pePartSize; 208 } 209 delete [] m_dpbPerCtuData; 210 m_dpbPerCtuData=NULL; 211 } 212 } 213 214 Void TComPicSym::destroy() 215 { 216 clearSliceBuffer(); 217 releaseAllReconstructionData(); 163 218 164 219 delete [] m_ctuTsToRsAddrMap; 165 220 m_ctuTsToRsAddrMap = NULL; -
source/Lib/TLibCommon/TComPicSym.h
105 105 UInt* m_puiTileIdxMap; ///< the map of the tile index relative to CTU raster scan address 106 106 UInt* m_ctuRsToTsAddrMap; ///< for a given RS (Raster-Scan) address, returns the TS (Tile-Scan; coding order) address. cf CtbAddrRsToTs in specification. 107 107 108 public: 109 struct DPBPerCtuData 110 { 111 Bool isInter(const UInt absPartAddr) const { return m_pePredMode[absPartAddr] == MODE_INTER; } 112 PartSize getPartitionSize( const UInt absPartAddr ) const { return static_cast<PartSize>( m_pePartSize[absPartAddr] ); } 113 const TComCUMvField* getCUMvField ( RefPicList e ) const { return &m_CUMvField[e]; } 114 const TComSlice* getSlice() const { return m_pSlice; } 115 116 SChar * m_pePredMode; 117 SChar * m_pePartSize; 118 TComCUMvField m_CUMvField[NUM_REF_PIC_LIST_01]; 119 TComSlice * m_pSlice; 120 }; 121 private: 122 DPBPerCtuData *m_dpbPerCtuData; 108 123 SAOBlkParam *m_saoBlkParams; 109 124 #if ADAPTIVE_QP_SELECTION 110 125 TCoeff* m_pParentARLBuffer; … … 120 135 Void setCtuRsToTsAddrMap( Int ctuRsAddr, Int ctuTsOrder ) { *(m_ctuRsToTsAddrMap + ctuRsAddr) = ctuTsOrder; } 121 136 122 137 public: 123 Void create ( const TComSPS &sps, const TComPPS &pps, UInt uiMaxDepth ); 138 Void create ( const TComSPS &sps, const TComPPS &pps, UInt uiMaxDepth, const Bool bAllocateCtuArray ); 139 Void prepareForReconstruction(); 140 Void releaseReconstructionIntermediateData(); 141 Void releaseAllReconstructionData(); 124 142 Void destroy (); 125 143 126 144 TComPicSym (); … … 137 155 const TComDataCU* getCtu( UInt ctuRsAddr ) const { return m_pictureCtuArray[ctuRsAddr]; } 138 156 const TComSPS& getSPS() const { return m_sps; } 139 157 const TComPPS& getPPS() const { return m_pps; } 158 DPBPerCtuData& getDPBPerCtuData(UInt ctuRsAddr) { return m_dpbPerCtuData[ctuRsAddr]; } 159 const DPBPerCtuData& getDPBPerCtuData(UInt ctuRsAddr) const { return m_dpbPerCtuData[ctuRsAddr]; } 140 160 141 161 TComSlice * swapSliceObject(TComSlice* p, UInt i) { p->setSPS(&m_sps); p->setPPS(&m_pps); TComSlice *pTmp=m_apSlices[i];m_apSlices[i] = p; pTmp->setSPS(0); pTmp->setPPS(0); return pTmp; } 142 162 UInt getNumAllocatedSlice() const { return UInt(m_apSlices.size()); } -
source/Lib/TLibDecoder/TDecTop.cpp
160 160 { 161 161 rpcPic = new TComPic(); 162 162 163 rpcPic->create ( sps, pps, true);163 rpcPic->create ( sps, pps, false, true); 164 164 165 165 m_cListPic.pushBack( rpcPic ); 166 166 … … 197 197 m_cListPic.pushBack( rpcPic ); 198 198 } 199 199 rpcPic->destroy(); 200 rpcPic->create ( sps, pps, true);200 rpcPic->create ( sps, pps, false, true); 201 201 } 202 202 203 203 Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic) -
source/Lib/TLibEncoder/TEncGOP.cpp
1159 1159 AccessUnit& accessUnit = accessUnitsInGOP.back(); 1160 1160 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr, isField ); 1161 1161 1162 pcPic->prepareForReconstruction(); 1163 1162 1164 // Slice data initialization 1163 1165 pcPic->clearSliceBuffer(); 1164 1166 pcPic->allocateNewSlice(); … … 1861 1863 { 1862 1864 iGOPid=effFieldIRAPMap.restoreGOPid(iGOPid); 1863 1865 } 1866 1867 pcPic->releaseReconstructionIntermediateData(); 1868 pcPic->releaseEncoderSourceImageData(); 1869 1864 1870 } // iGOPid-loop 1865 1871 1866 1872 delete pcBitstreamRedirect; -
source/Lib/TLibEncoder/TEncPic.cpp
121 121 * \param uiMaxAdaptiveQPDepth Maximum depth of unit block for assigning QP adaptive to local image characteristics 122 122 * \param bIsVirtual 123 123 */ 124 Void TEncPic::create( const TComSPS &sps, const TComPPS &pps, UInt uiMaxAdaptiveQPDepth , Bool bIsVirtual)124 Void TEncPic::create( const TComSPS &sps, const TComPPS &pps, UInt uiMaxAdaptiveQPDepth ) 125 125 { 126 TComPic::create( sps, pps, bIsVirtual);126 TComPic::create( sps, pps, true, false ); 127 127 const Int iWidth = sps.getPicWidthInLumaSamples(); 128 128 const Int iHeight = sps.getPicHeightInLumaSamples(); 129 129 const UInt uiMaxWidth = sps.getMaxCUWidth(); -
source/Lib/TLibEncoder/TEncPic.h
102 102 TEncPic(); 103 103 virtual ~TEncPic(); 104 104 105 Void create( const TComSPS &sps, const TComPPS &pps, UInt uiMaxAdaptiveQPDepth , Bool bIsVirtual /* = false*/);105 Void create( const TComSPS &sps, const TComPPS &pps, UInt uiMaxAdaptiveQPDepth ); 106 106 virtual Void destroy(); 107 107 108 108 TEncPicQPAdaptationLayer* getAQLayer( UInt uiDepth ) { return &m_acAQLayer[uiDepth]; } -
source/Lib/TLibEncoder/TEncTop.cpp
491 491 break; 492 492 } 493 493 } 494 rpcPic->releaseAllReconstructionData(); 495 rpcPic->prepareForEncoderSourcePicYuv(); 494 496 } 495 497 else 496 498 { 497 499 if ( getUseAdaptiveQP() ) 498 500 { 499 501 TEncPic* pcEPic = new TEncPic; 500 pcEPic->create( m_cSPS, m_cPPS, m_cPPS.getMaxCuDQPDepth()+1 , false);502 pcEPic->create( m_cSPS, m_cPPS, m_cPPS.getMaxCuDQPDepth()+1); 501 503 rpcPic = pcEPic; 502 504 } 503 505 else 504 506 { 505 507 rpcPic = new TComPic; 506 rpcPic->create( m_cSPS, m_cPPS, false );508 rpcPic->create( m_cSPS, m_cPPS, true, false ); 507 509 } 508 510 509 511 m_cListPic.pushBack( rpcPic ); … … 514 516 m_iNumPicRcvd++; 515 517 516 518 rpcPic->getSlice(0)->setPOC( m_iPOCLast ); 517 // mark it should be extended518 rpcPic->getPicYuvRec()->setBorderExtension(false);519 519 } 520 520 521 521 Void TEncTop::xInitVPS()