Changeset 56 in 3DVCSoftware for trunk/source/Lib/TLibEncoder/TEncTop.cpp
- Timestamp:
- 11 May 2012, 21:20:17 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibEncoder/TEncTop.cpp
r42 r56 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 1,ISO/IEC6 * Copyright (c) 2010-2012, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 15 15 * this list of conditions and the following disclaimer in the documentation 16 16 * and/or other materials provided with the distribution. 17 * * Neither the name of the I SO/IEC nor the names of its contributors may17 * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may 18 18 * be used to endorse or promote products derived from this software without 19 19 * specific prior written permission. … … 32 32 */ 33 33 34 35 36 34 /** \file TEncTop.cpp 37 35 \brief encoder class 38 36 */ 39 37 40 #include " ../TLibCommon/CommonDef.h"38 #include "TLibCommon/CommonDef.h" 41 39 #include "TEncTop.h" 42 43 #include "TEncGOP.h" 40 #include "TEncPic.h" 44 41 #include "../../App/TAppEncoder/TAppEncTop.h" 42 #if FAST_BIT_EST 43 #include "TLibCommon/ContextModel.h" 44 #endif 45 46 //! \ingroup TLibEncoder 47 //! \{ 45 48 46 49 // ==================================================================================================================== … … 61 64 g_nSymbolCounter = 0; 62 65 #endif 63 m_bSeqFirst = true; 64 m_iFrameNumInCodingOrder = 0; 66 67 m_iMaxRefPicNum = 0; 68 69 #if FAST_BIT_EST 70 ContextModel::buildNextStateTable(); 71 #endif 72 73 m_pcSbacCoders = NULL; 74 m_pcBinCoderCABACs = NULL; 75 m_ppppcRDSbacCoders = NULL; 76 m_ppppcBinCodersCABAC = NULL; 77 m_pcRDGoOnSbacCoders = NULL; 78 m_pcRDGoOnBinCodersCABAC = NULL; 79 m_pcBitCounters = NULL; 80 m_pcRdCosts = NULL; 65 81 } 66 82 … … 75 91 { 76 92 // initialize global variables 77 if(m_uiViewId<1 && !m_bIsDepth) 78 initROM(); 79 93 initROM(); 94 80 95 // create processing unit classes 81 m_c PicEncoder. create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight );96 m_cGOPEncoder. create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight ); 82 97 m_cSliceEncoder. create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 83 98 m_cCuEncoder. create( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); 84 #if MTK_SAO85 99 if (m_bUseSAO) 86 100 { 101 #if SAO_UNIT_INTERLEAVING 102 m_cEncSAO.setSaoInterleavingFlag(getSaoInterleavingFlag()); 103 m_cEncSAO.setMaxNumOffsetsPerPic(getMaxNumOffsetsPerPic()); 104 #endif 87 105 m_cEncSAO.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 88 106 m_cEncSAO.createEncBuffer(); 89 107 } 108 #if ADAPTIVE_QP_SELECTION 109 if (m_bUseAdaptQpSelect) 110 { 111 m_cTrQuant.initSliceQpDelta(); 112 } 90 113 #endif 91 114 m_cAdaptiveLoopFilter.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 92 115 m_cLoopFilter. create( g_uiMaxCUDepth ); 116 93 117 #if DEPTH_MAP_GENERATION 94 118 m_cDepthMapGenerator. create( false, getSourceWidth(), getSourceHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(m_uiPredDepthMapGeneration), PDM_SUB_SAMP_EXP_Y(m_uiPredDepthMapGeneration) ); … … 98 122 #endif 99 123 100 #if MQT_BA_RA && MQT_ALF_NPASS101 124 if(m_bUseALF) 102 125 { 126 #if LCU_SYNTAX_ALF 127 m_cAdaptiveLoopFilter.setAlfCoefInSlice(m_bALFParamInSlice); 128 m_cAdaptiveLoopFilter.createAlfGlobalBuffers(); 129 #else 130 m_cAdaptiveLoopFilter.setGOPSize( getGOPSize() ); 103 131 m_cAdaptiveLoopFilter.createAlfGlobalBuffers(m_iALFEncodePassReduction); 104 } 105 #endif 132 #endif 133 } 134 135 if(m_bUseSAO || m_bUseALF) 136 { 137 m_vAPS.reserve(MAX_NUM_SUPPORTED_APS); 138 } 106 139 107 140 // if SBAC-based RD optimization is used 108 141 if( m_bUseSBACRD ) 109 142 { 110 UInt uiNumCEnc = 1 + Max( g_uiMaxCUDepth, AO_MAX_DEPTH ); // HS: prevents crash in SAO for small maximum CU sizes 111 m_pppcRDSbacCoder = new TEncSbac** [uiNumCEnc]; 112 m_pppcBinCoderCABAC = new TEncBinCABAC** [uiNumCEnc]; 113 114 for ( Int iDepth = 0; iDepth < uiNumCEnc; iDepth++ ) 143 m_pppcRDSbacCoder = new TEncSbac** [g_uiMaxCUDepth+1]; 144 #if FAST_BIT_EST 145 m_pppcBinCoderCABAC = new TEncBinCABACCounter** [g_uiMaxCUDepth+1]; 146 #else 147 m_pppcBinCoderCABAC = new TEncBinCABAC** [g_uiMaxCUDepth+1]; 148 #endif 149 150 for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 115 151 { 116 152 m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM]; 153 #if FAST_BIT_EST 154 m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM]; 155 #else 117 156 m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM]; 118 157 #endif 158 119 159 for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) 120 160 { 121 161 m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac; 162 #if FAST_BIT_EST 163 m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter; 164 #else 122 165 m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC; 166 #endif 123 167 m_pppcRDSbacCoder [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] ); 124 168 } 125 169 } 126 170 } 127 171 m_pcTAppEncTop = NULL; 128 172 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 129 if( g_aacWedgeLists.empty() && m_bUseDMM && m_bIsDepth)173 if( g_aacWedgeLists.empty() && m_bUseDMM ) 130 174 { 131 175 initWedgeLists(); … … 134 178 } 135 179 180 /** 181 - Allocate coders required for wavefront for the nominated number of substreams. 182 . 183 \param iNumSubstreams Determines how much information to allocate. 184 */ 185 Void TEncTop::createWPPCoders(Int iNumSubstreams) 186 { 187 if (m_pcSbacCoders != NULL) 188 return; // already generated. 189 190 m_iNumSubstreams = iNumSubstreams; 191 m_pcSbacCoders = new TEncSbac [iNumSubstreams]; 192 m_pcBinCoderCABACs = new TEncBinCABAC [iNumSubstreams]; 193 m_pcRDGoOnSbacCoders = new TEncSbac [iNumSubstreams]; 194 m_pcRDGoOnBinCodersCABAC = new TEncBinCABAC [iNumSubstreams]; 195 m_pcBitCounters = new TComBitCounter [iNumSubstreams]; 196 m_pcRdCosts = new TComRdCost [iNumSubstreams]; 197 198 for ( UInt ui = 0 ; ui < iNumSubstreams; ui++ ) 199 { 200 m_pcRDGoOnSbacCoders[ui].init( &m_pcRDGoOnBinCodersCABAC[ui] ); 201 m_pcSbacCoders[ui].init( &m_pcBinCoderCABACs[ui] ); 202 } 203 if( m_bUseSBACRD ) 204 { 205 m_ppppcRDSbacCoders = new TEncSbac*** [iNumSubstreams]; 206 m_ppppcBinCodersCABAC = new TEncBinCABAC***[iNumSubstreams]; 207 for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ ) 208 { 209 m_ppppcRDSbacCoders[ui] = new TEncSbac** [g_uiMaxCUDepth+1]; 210 m_ppppcBinCodersCABAC[ui]= new TEncBinCABAC** [g_uiMaxCUDepth+1]; 211 212 for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 213 { 214 m_ppppcRDSbacCoders[ui][iDepth] = new TEncSbac* [CI_NUM]; 215 m_ppppcBinCodersCABAC[ui][iDepth]= new TEncBinCABAC* [CI_NUM]; 216 217 for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) 218 { 219 m_ppppcRDSbacCoders [ui][iDepth][iCIIdx] = new TEncSbac; 220 m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] = new TEncBinCABAC; 221 m_ppppcRDSbacCoders [ui][iDepth][iCIIdx]->init( m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] ); 222 } 223 } 224 } 225 } 226 } 227 136 228 Void TEncTop::destroy () 137 229 { 138 #if MQT_BA_RA && MQT_ALF_NPASS139 230 if(m_bUseALF) 140 231 { 141 232 m_cAdaptiveLoopFilter.destroyAlfGlobalBuffers(); 142 233 } 143 #endif 234 235 for(Int i=0; i< m_vAPS.size(); i++) 236 { 237 TComAPS& cAPS = m_vAPS[i]; 238 m_cGOPEncoder.freeAPS(&cAPS, &m_cSPS); 239 } 144 240 145 241 // destroy processing unit classes 146 m_c PicEncoder. destroy();242 m_cGOPEncoder. destroy(); 147 243 m_cSliceEncoder. destroy(); 148 244 m_cCuEncoder. destroy(); 149 #if MTK_SAO150 245 if (m_cSPS.getUseSAO()) 151 246 { 152 247 m_cEncSAO.destroy(); 153 m_cEncSAO.destoryEncBuffer(); 154 } 155 #endif 248 m_cEncSAO.destroyEncBuffer(); 249 } 156 250 m_cAdaptiveLoopFilter.destroy(); 157 251 m_cLoopFilter. destroy(); 252 158 253 #if DEPTH_MAP_GENERATION 159 254 m_cDepthMapGenerator. destroy(); … … 163 258 #endif 164 259 260 m_RPSList. destroy(); 261 165 262 // SBAC RD 166 263 if( m_bUseSBACRD ) … … 175 272 } 176 273 } 177 274 178 275 for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 179 276 { … … 181 278 delete [] m_pppcBinCoderCABAC[iDepth]; 182 279 } 183 280 184 281 delete [] m_pppcRDSbacCoder; 185 282 delete [] m_pppcBinCoderCABAC; 186 } 187 283 284 for ( UInt ui = 0; ui < m_iNumSubstreams; ui++ ) 285 { 286 for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 287 { 288 for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) 289 { 290 delete m_ppppcRDSbacCoders [ui][iDepth][iCIIdx]; 291 delete m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx]; 292 } 293 } 294 295 for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 296 { 297 delete [] m_ppppcRDSbacCoders [ui][iDepth]; 298 delete [] m_ppppcBinCodersCABAC[ui][iDepth]; 299 } 300 delete[] m_ppppcRDSbacCoders [ui]; 301 delete[] m_ppppcBinCodersCABAC[ui]; 302 } 303 delete[] m_ppppcRDSbacCoders; 304 delete[] m_ppppcBinCodersCABAC; 305 } 306 delete[] m_pcSbacCoders; 307 delete[] m_pcBinCoderCABACs; 308 delete[] m_pcRDGoOnSbacCoders; 309 delete[] m_pcRDGoOnBinCodersCABAC; 310 delete[] m_pcBitCounters; 311 delete[] m_pcRdCosts; 312 188 313 // destroy ROM 189 if(m_uiViewId<1 && !m_bIsDepth) 190 destroyROM(); 191 314 if(m_viewId == 0 && m_isDepth == false) 315 { 316 destroyROM(); 317 } 318 192 319 return; 193 320 } … … 196 323 { 197 324 UInt *aTable4=NULL, *aTable8=NULL; 198 #if QC_MOD_LCEC 199 UInt* aTableLastPosVlcIndex=NULL; 200 #endif 325 UInt* aTableLastPosVlcIndex=NULL; 201 326 // initialize SPS 202 327 xInitSPS(); 203 204 #if CONSTRAINED_INTRA_PRED 328 205 329 // initialize PPS 330 m_cPPS.setSPS(&m_cSPS); 331 #if RPS_IN_SPS 332 m_cSPS.setRPSList(&m_RPSList); 333 #else 334 m_cPPS.setRPSList(&m_RPSList); 335 #endif 206 336 xInitPPS(); 207 #endif 337 xInitRPS(); 338 339 xInitSPSforInterViewRefs(); 340 xInitPPSforTiles(); 208 341 209 342 // initialize processing unit classes 210 m_c PicEncoder. init( this );343 m_cGOPEncoder. init( this ); 211 344 m_cSliceEncoder.init( this ); 212 345 m_cCuEncoder. init( this ); 213 346 214 347 m_pcTAppEncTop = pcTAppEncTop; 348 215 349 #if DEPTH_MAP_GENERATION 216 350 m_cDepthMapGenerator.init( (TComPrediction*)this->getPredSearch(), m_pcTAppEncTop->getSPSAccess(), m_pcTAppEncTop->getAUPicAccess() ); … … 222 356 // initialize transform & quantization class 223 357 m_pcCavlcCoder = getCavlcCoder(); 224 #if !CAVLC_COEF_LRG_BLK 225 aTable8 = m_pcCavlcCoder->GetLP8Table(); 226 #endif 227 aTable4 = m_pcCavlcCoder->GetLP4Table(); 228 #if QC_MOD_LCEC 229 aTableLastPosVlcIndex=m_pcCavlcCoder->GetLastPosVlcIndexTable(); 230 231 m_cTrQuant.init( g_uiMaxCUWidth, g_uiMaxCUHeight, 1 << m_uiQuadtreeTULog2MaxSize, m_iSymbolMode, aTable4, aTable8, 232 aTableLastPosVlcIndex, m_bUseRDOQ, true ); 233 #else 234 m_cTrQuant.init( g_uiMaxCUWidth, g_uiMaxCUHeight, 1 << m_uiQuadtreeTULog2MaxSize, m_iSymbolMode, aTable4, aTable8, m_bUseRDOQ, true ); 235 #endif 236 358 359 m_cTrQuant.init( g_uiMaxCUWidth, g_uiMaxCUHeight, 1 << m_uiQuadtreeTULog2MaxSize, 360 0, 361 aTable4, aTable8, 362 aTableLastPosVlcIndex, m_bUseRDOQ, true 363 #if ADAPTIVE_QP_SELECTION 364 , m_bUseAdaptQpSelect 365 #endif 366 ); 367 237 368 // initialize encoder search class 238 369 m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_iFastSearch, 0, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() ); 239 m_cSeqIter = TEncSeqStructure::Iterator( m_cSequenceStructure, 0, 0 ); 240 m_bPicWaitingForCoding = false ; 241 242 #if MQT_ALF_NPASS 370 243 371 if(m_bUseALF) 244 372 { 245 373 m_cAdaptiveLoopFilter.setALFEncodePassReduction( m_iALFEncodePassReduction ); 246 } 247 #endif 374 m_cAdaptiveLoopFilter.setALFMaxNumberFilters( m_iALFMaxNumberFilters ); 375 #if LCU_SYNTAX_ALF 376 m_cAdaptiveLoopFilter.initPicQuadTreePartition(m_bALFPicBasedEncode ); 377 #endif 378 } 379 380 m_iMaxRefPicNum = 0; 248 381 } 249 382 … … 252 385 // ==================================================================================================================== 253 386 387 Void TEncTop::initNewPic( TComPicYuv* pcPicYuvOrg, TComPicYuv* pcOrgPdmDepth ) 388 { 389 TComPic* pcPicCurr = NULL; 390 391 // get original YUV 392 xGetNewPicBuffer( pcPicCurr ); 393 pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); 394 395 #if SONY_COLPIC_AVAILABILITY 396 pcPicCurr->setViewOrderIdx(m_iViewOrderIdx); 397 #endif 398 pcPicCurr->setScaleOffset( m_aaiCodedScale, m_aaiCodedOffset ); 399 400 #if HHI_INTER_VIEW_MOTION_PRED 401 if( m_uiMultiviewMvRegMode ) 402 { 403 AOF( pcOrgPdmDepth ); 404 AOF( pcPicCurr->getOrgDepthMap() ); 405 pcOrgPdmDepth->copyToPic( pcPicCurr->getOrgDepthMap() ); 406 } 407 else 408 { 409 AOT( pcOrgPdmDepth ); 410 AOT( pcPicCurr->getOrgDepthMap() ); 411 } 412 #endif 413 414 #if DEPTH_MAP_GENERATION 415 // add extra pic buffers 416 Bool bNeedPrdDepthMapBuf = ( m_uiPredDepthMapGeneration > 0 ); 417 if( bNeedPrdDepthMapBuf && !pcPicCurr->getPredDepthMap() ) 418 { 419 pcPicCurr->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(m_uiPredDepthMapGeneration), PDM_SUB_SAMP_EXP_Y(m_uiPredDepthMapGeneration) ); 420 } 421 #endif 422 423 // compute image characteristics 424 if ( getUseAdaptiveQP() ) 425 { 426 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) ); 427 } 428 } 429 254 430 Void TEncTop::deletePicBuffer() 255 431 { 256 432 TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); 257 433 Int iSize = Int( m_cListPic.size() ); 258 434 259 435 for ( Int i = 0; i < iSize; i++ ) 260 436 { 261 437 TComPic* pcPic = *(iterPic++); 262 438 263 439 pcPic->destroy(); 264 440 delete pcPic; … … 278 454 \retval iNumEncoded number of encoded pictures 279 455 */ 280 Void TEncTop::encode( bool bEos, std::map<PicOrderCnt, TComPicYuv*>& rcMapPicYuvRecOut, TComBitstream* pcBitstreamOut, Bool& bNewPicNeeded ) 281 { 282 283 // TComBitstream* pcBitstreamOut ; 284 TComPicYuv* pcPicYuvRecOut; 285 TComPic* pcOrgRefList[2][MAX_REF_PIC_NUM]; //GT: not used? 286 TComPic* pcPic ; 287 288 bool bSomethingCoded = false ; 289 #if FLEX_CODING_ORDER 290 if (TEncTop::m_bPicWaitingForCoding ) 291 #else 292 if (m_bPicWaitingForCoding ) 293 #endif 294 { 295 std::map<Int, TComPic*>::iterator cIter = m_acInputPicMap.find( (Int)m_cSeqIter.getPoc() ); 296 const bool bPictureAvailable = cIter != m_acInputPicMap.end(); 297 if (bPictureAvailable) //GT: it is possible that poc to code is not in input-picmap, but m_bPicWaitingForCoding is true, since current poc is beyond sequence-end 298 { 299 assert( m_acOutputPicMap.find( m_cSeqIter.getPoc() ) != m_acOutputPicMap.end() ); 300 pcPicYuvRecOut = m_acOutputPicMap[m_cSeqIter.getPoc()]; 301 m_acOutputPicMap.erase( m_cSeqIter.getPoc() ); 302 pcPic = cIter->second ; 303 304 #if DEPTH_MAP_GENERATION 305 // add extra pic buffers 306 Bool bNeedPrdDepthMapBuf = ( m_uiPredDepthMapGeneration > 0 ); 307 if( bNeedPrdDepthMapBuf && !pcPic->getPredDepthMap() ) 308 { 309 pcPic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(m_uiPredDepthMapGeneration), PDM_SUB_SAMP_EXP_Y(m_uiPredDepthMapGeneration) ); 310 } 311 #endif 312 313 // needed? dont think so 314 TComPicYuv cPicOrg; 315 cPicOrg.create( pcPic->getPicYuvOrg()->getWidth(), pcPic->getPicYuvOrg()->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 316 pcPic->getPicYuvOrg()->copyToPic( &cPicOrg ); 317 xSetPicProperties( pcPic) ; 318 m_cPicEncoder.compressPic( pcBitstreamOut, cPicOrg, pcPic, pcPicYuvRecOut, pcOrgRefList, m_bSeqFirst, m_cListPic); 319 bSomethingCoded = true; 320 m_acInputPicMap.erase( cIter ); 321 cPicOrg.destroy() ; 322 assert( rcMapPicYuvRecOut.find( pcPic->getPOC() ) == rcMapPicYuvRecOut.end() ); 323 rcMapPicYuvRecOut[pcPic->getPOC()] = pcPicYuvRecOut; 324 } 325 else if(m_uiViewId==-1) 326 printf("\nPOC %4d skipped due to sequence end", Int(m_cSeqIter.getPoc()) ); 327 else 328 { 329 if( m_bIsDepth ) 330 { 331 printf("\nDepth View \t%4d\t POC %4d skipped due to sequence end", m_uiViewId, Int(m_cSeqIter.getPoc() )); 332 } 333 else 334 { 335 printf("\nView \t\t%4d\t POC %4d skipped due to sequence end", m_uiViewId, Int(m_cSeqIter.getPoc() )); 336 } 337 } 338 ++m_cSeqIter; //GT: increment, even bPictureAvailable might be false, (POC beyond sequence end); 339 340 Bool hitSeqEndButHasToCode = bEos && !m_acInputPicMap.empty(); 341 if( (m_acInputPicMap.find( (Int)m_cSeqIter.getPoc() ) != m_acInputPicMap.end()) || hitSeqEndButHasToCode ) //GT: new poc also in InputList 342 { 343 m_bPicWaitingForCoding = true; 344 bNewPicNeeded = false ; 345 } 346 else 347 { 348 m_bPicWaitingForCoding = false; 349 bNewPicNeeded = true ; 350 } 351 } 352 353 354 if(bSomethingCoded && !m_bPicWaitingForCoding ) //GT: no gaps any more 355 { 356 m_uiNumAllPicCoded += m_iNumPicRcvd; 456 Void TEncTop::encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Int gopId ) 457 { 458 459 if( gopId == 0) 460 { 461 m_cGOPEncoder.initGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut); 462 } 463 464 { 465 m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, gopId ); 466 } 467 468 if( gopId + 1 == m_cGOPEncoder.getGOPSize() ) 469 { 470 iNumEncoded = m_iNumPicRcvd; 357 471 m_iNumPicRcvd = 0; 358 } 359 360 361 if (bEos&&m_uiViewId==-1) 362 { 363 printOutSummary (m_uiNumAllPicCoded); 364 } 365 } 366 367 368 Void TEncTop::receivePic( bool bEos, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvRec, TComPicYuv* pcOrgPdmDepth ) 369 { 370 if( !m_bPicWaitingForCoding ) //GT: insert pcPicYuvOrg in m_acInputPicMap and m_cListPic 371 { 372 TComPic* pcPicCurr = NULL; 373 xGetNewPicBuffer( pcPicCurr ); //GT: assigns next POC to input pic and stores it in m_cListPic 374 pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); 375 #if HHI_INTER_VIEW_MOTION_PRED 376 if( m_uiMultiviewMvRegMode ) 377 { 378 AOF( pcOrgPdmDepth ); 379 AOF( pcPicCurr->getOrgDepthMap() ); 380 pcOrgPdmDepth->copyToPic( pcPicCurr->getOrgDepthMap() ); 381 } 382 else 383 { 384 AOT( pcOrgPdmDepth ); 385 AOT( pcPicCurr->getOrgDepthMap() ); 386 } 387 #endif 388 m_acInputPicMap.insert( std::make_pair(pcPicCurr->getPOC(), pcPicCurr)); //GT: input pic to m_acInputPicMap 389 assert( m_acOutputPicMap.find( pcPicCurr->getPOC() ) == m_acOutputPicMap.end() ); 390 m_acOutputPicMap[pcPicCurr->getPOC()] = pcPicYuvRec; 391 } 392 393 bool hitSeqEndButHasToCode = bEos && !m_acInputPicMap.empty(); //GT: End of sequence has been reached, but still pictures to code left 394 m_bPicWaitingForCoding = m_bPicWaitingForCoding || hitSeqEndButHasToCode ; 395 396 if( m_acInputPicMap.find( (Int)m_cSeqIter.getPoc() ) != m_acInputPicMap.end() ) //GT: If poc to code is in input-picmap; not necessary 397 { 398 m_bPicWaitingForCoding = true; 399 } 400 } 401 402 472 m_uiNumAllPicCoded += iNumEncoded; 473 } 474 } 475 476 477 #if HHI_INTERVIEW_SKIP || HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED 403 478 Void 404 479 TEncTop::deleteExtraPicBuffers( Int iPoc ) … … 418 493 if ( pcPic ) 419 494 { 420 pcPic->removeOriginalBuffer ();421 495 #if HHI_INTER_VIEW_MOTION_PRED 422 496 pcPic->removeOrgDepthMapBuffer(); … … 430 504 } 431 505 } 432 433 434 #if AMVP_BUFFERCOMPRESS 506 #endif 507 435 508 Void 436 509 TEncTop::compressMotion( Int iPoc ) … … 453 526 } 454 527 } 455 #endif456 457 458 528 459 529 // ==================================================================================================================== … … 471 541 { 472 542 TComSlice::sortPicList(m_cListPic); 473 474 // bug-fix - erase frame memory (previous GOP) which is not used for reference any more 475 if (m_cListPic.size() >= m_uiCodedPictureStoreSize ) // 2) // K. Lee bug fix - for multiple reference > 2 476 { 477 rpcPic = m_cListPic.popFront(); 478 479 // is it necessary without long-term reference? 543 544 #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER 545 if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) ) 546 #else 547 if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxNumberOfReferencePictures() + 2) ) 548 #endif 549 { 550 TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); 551 Int iSize = Int( m_cListPic.size() ); 552 for ( Int i = 0; i < iSize; i++ ) 553 { 554 rpcPic = *(++iterPic); 555 if(rpcPic->getSlice(0)->isReferenced() == false) 556 break; 557 } 480 558 } 481 559 else 482 560 { 483 rpcPic = new TComPic; 484 rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 485 } 486 487 m_cListPic.pushBack( rpcPic ); 561 if ( getUseAdaptiveQP() ) 562 { 563 TEncPic* pcEPic = new TEncPic; 564 pcEPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 ); 565 rpcPic = pcEPic; 566 } 567 else 568 { 569 rpcPic = new TComPic; 570 rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 571 } 572 m_cListPic.pushBack( rpcPic ); 573 } 574 #if HHI_INTERVIEW_SKIP 575 if( m_bInterViewSkip ) 576 { 577 rpcPic->addUsedPelsMapBuffer(); 578 } 579 #endif 488 580 rpcPic->setReconMark (false); 489 581 490 582 m_iPOCLast++; 491 583 m_iNumPicRcvd++; 492 493 rpcPic->addOriginalBuffer(); 584 494 585 #if HHI_INTER_VIEW_MOTION_PRED 495 586 if( m_uiMultiviewMvRegMode ) … … 498 589 } 499 590 #endif 500 501 #if HHI_INTERVIEW_SKIP 502 if( getInterViewSkip() ) 503 { 504 rpcPic->addUsedPelsMapBuffer(); 505 } 506 #endif 507 508 rpcPic->setCurrSliceIdx( 0 ); // MW 591 509 592 rpcPic->getSlice(0)->setPOC( m_iPOCLast ); 510 511 593 // mark it should be extended 512 594 rpcPic->getPicYuvRec()->setBorderExtension(false); 513 595 } 514 596 515 516 597 Void TEncTop::xInitSPS() 517 598 { 518 m_cSPS.setWidth ( m_iSourceWidth ); 519 m_cSPS.setHeight ( m_iSourceHeight ); 599 m_cSPS.setPicWidthInLumaSamples ( m_iSourceWidth ); 600 m_cSPS.setPicHeightInLumaSamples ( m_iSourceHeight ); 601 #if PIC_CROPPING 602 m_cSPS.setPicCroppingFlag( m_croppingMode!= 0 ); 603 if (m_croppingMode != 0) 604 { 605 m_cSPS.setPicCropLeftOffset( m_cropLeft ); 606 m_cSPS.setPicCropRightOffset( m_cropRight ); 607 m_cSPS.setPicCropTopOffset( m_cropTop ); 608 m_cSPS.setPicCropBottomOffset( m_cropBottom ); 609 } 610 #else 520 611 m_cSPS.setPad ( m_aiPad ); 612 #endif 521 613 m_cSPS.setMaxCUWidth ( g_uiMaxCUWidth ); 522 614 m_cSPS.setMaxCUHeight ( g_uiMaxCUHeight ); … … 524 616 m_cSPS.setMinTrDepth ( 0 ); 525 617 m_cSPS.setMaxTrDepth ( 1 ); 618 619 #if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER 620 m_cSPS.setMaxNumberOfReferencePictures(m_maxNumberOfReferencePictures); 621 m_cSPS.setNumReorderFrames(m_numReorderFrames); 622 #endif 623 m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize); 624 m_cSPS.setUsePCM ( m_usePCM ); 625 m_cSPS.setPCMLog2MaxSize( m_pcmLog2MaxSize ); 526 626 527 627 m_cSPS.setUseALF ( m_bUseALF ); 528 628 #if LCU_SYNTAX_ALF 629 if(m_bUseALF) 630 { 631 m_cSPS.setUseALFCoefInSlice(m_bALFParamInSlice); 632 } 633 #endif 634 529 635 m_cSPS.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize ); 530 636 m_cSPS.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize ); 531 637 m_cSPS.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter ); 532 638 m_cSPS.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra ); 533 534 m_cSPS.setUseDQP ( m_iMaxDeltaQP != 0 ); 535 #if !HHI_NO_LowDelayCoding 536 m_cSPS.setUseLDC ( m_bUseLDC ); 537 # endif639 640 #if LOSSLESS_CODING 641 m_cSPS.setUseLossless ( m_useLossless ); 642 #endif 643 #if !PIC_CROPPING 538 644 m_cSPS.setUsePAD ( m_bUsePAD ); 539 540 m_cSPS.setUseMRG ( m_bUseMRG ); // SOPH: 541 542 #if LM_CHROMA 543 m_cSPS.setUseLMChroma ( m_bUseLMChroma ); 544 #endif 545 645 #endif 646 m_cSPS.setUseLMChroma ( m_bUseLMChroma ); 647 546 648 m_cSPS.setMaxTrSize ( 1 << m_uiQuadtreeTULog2MaxSize ); 547 548 #if BITSTREAM_EXTRACTION 549 m_cSPS.setLayerId( m_uiLayerId ); 550 #endif 551 552 if( m_bIsDepth ) 553 { 554 m_cSPS.initMultiviewSPSDepth ( m_uiViewId, m_iViewOrderIdx ); 555 #if DEPTH_MAP_GENERATION 556 m_cSPS.setPredDepthMapGeneration( m_uiViewId, true ); 557 #endif 558 #if HHI_INTER_VIEW_RESIDUAL_PRED 559 m_cSPS.setMultiviewResPredMode ( 0 ); 560 #endif 561 } 562 else 563 { 564 m_cSPS.initMultiviewSPS ( m_uiViewId, m_iViewOrderIdx, m_uiCamParPrecision, m_bCamParInSliceHeader, m_aaiCodedScale, m_aaiCodedOffset ); 565 if( m_uiViewId ) 566 { 567 #if DEPTH_MAP_GENERATION 568 #if HHI_INTER_VIEW_MOTION_PRED 569 m_cSPS.setPredDepthMapGeneration( m_uiViewId, false, m_uiPredDepthMapGeneration, m_uiMultiviewMvPredMode, m_uiPdmPrecision, m_aaiPdmScaleNomDelta, m_aaiPdmOffset ); 570 #else 571 m_cSPS.setPredDepthMapGeneration( m_uiViewId, false, m_uiPredDepthMapGeneration, 0, m_uiPdmPrecision, m_aaiPdmScaleNomDelta, m_aaiPdmOffset ); 572 #endif 573 #endif 574 #if HHI_INTER_VIEW_RESIDUAL_PRED 575 m_cSPS.setMultiviewResPredMode ( m_uiMultiviewResPredMode ); 576 #endif 577 } 578 else 579 { 580 #if DEPTH_MAP_GENERATION 581 m_cSPS.setPredDepthMapGeneration( m_uiViewId, false ); 582 #endif 583 #if HHI_INTER_VIEW_RESIDUAL_PRED 584 m_cSPS.setMultiviewResPredMode ( 0 ); 585 #endif 586 } 587 } 588 m_cSPS.setSPSId( ( m_uiViewId << 1 ) + ( m_bIsDepth ? 1 : 0 ) ); 589 590 #if DCM_COMB_LIST 649 591 650 m_cSPS.setUseLComb ( m_bUseLComb ); 592 651 m_cSPS.setLCMod ( m_bLCMod ); 593 #endif 594 652 m_cSPS.setUseNSQT( m_useNSQT ); 653 595 654 Int i; 596 655 #if HHI_AMVP_OFF … … 605 664 } 606 665 #endif 607 608 609 #if HHI_RMP_SWITCH 610 m_cSPS.setUseRMP( m_bUseRMP ); 611 #endif 666 667 for (i = 0; i < g_uiMaxCUDepth-1; i++ ) 668 { 669 m_cSPS.setAMPAcc( i, m_useAMP ); 670 //m_cSPS.setAMPAcc( i, 1 ); 671 } 672 673 m_cSPS.setUseAMP ( m_useAMP ); 674 675 for (i = g_uiMaxCUDepth-1; i < g_uiMaxCUDepth; i++ ) 676 { 677 m_cSPS.setAMPAcc(i, 0); 678 } 612 679 613 680 m_cSPS.setBitDepth ( g_uiBitDepth ); 614 681 m_cSPS.setBitIncrement( g_uiBitIncrement ); 615 616 #if MTK_NONCROSS_INLOOP_FILTER 682 #if H0736_AVC_STYLE_QP_RANGE 683 m_cSPS.setQpBDOffsetY ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) ); 684 m_cSPS.setQpBDOffsetC ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) ); 685 #endif 686 617 687 m_cSPS.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); 618 #endif 619 #if MTK_SAO 620 m_cSPS.setUseSAO ( m_bUseSAO ); 621 #endif 688 m_cSPS.setUseSAO( m_bUseSAO ); 689 690 #if !H0566_TLA 691 if ( m_bTLayering ) 692 { 693 Int iMaxTLayers = 1; 694 for ( i = 1; ; i++) 695 { 696 iMaxTLayers = i; 697 if ( (m_iGOPSize >> i) == 0 ) 698 { 699 break; 700 } 701 } 702 703 m_cSPS.setMaxTLayers( (UInt)iMaxTLayers ); 704 705 Bool bTemporalIdNestingFlag = true; 706 for ( i = 0; i < m_cSPS.getMaxTLayers()-1; i++ ) 707 { 708 if ( !m_abTLayerSwitchingFlag[i] ) 709 { 710 bTemporalIdNestingFlag = false; 711 break; 712 } 713 } 714 715 m_cSPS.setTemporalIdNestingFlag( bTemporalIdNestingFlag ); 716 } 717 else 718 { 719 m_cSPS.setMaxTLayers( 1 ); 720 m_cSPS.setTemporalIdNestingFlag( false ); 721 } 722 #else 723 m_cSPS.setMaxTLayers( m_maxTempLayer ); 724 m_cSPS.setTemporalIdNestingFlag( false ); 725 #endif 726 #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER 727 for ( i = 0; i < m_cSPS.getMaxTLayers(); i++ ) 728 { 729 m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i); 730 m_cSPS.setNumReorderPics(m_numReorderPics[i], i); 731 } 732 #endif 733 m_cSPS.setPCMBitDepthLuma (g_uiPCMBitDepthLuma); 734 m_cSPS.setPCMBitDepthChroma (g_uiPCMBitDepthChroma); 735 m_cSPS.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag ); 736 737 m_cSPS.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); 738 m_cSPS.setUniformSpacingIdr( m_iUniformSpacingIdr ); 739 #if !REMOVE_TILE_DEPENDENCE 740 m_cSPS.setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr ); 741 #endif 742 m_cSPS.setNumColumnsMinus1( m_iNumColumnsMinus1 ); 743 m_cSPS.setNumRowsMinus1( m_iNumRowsMinus1 ); 744 if( m_iUniformSpacingIdr == 0 ) 745 { 746 m_cSPS.setColumnWidth( m_puiColumnWidth ); 747 m_cSPS.setRowHeight( m_puiRowHeight ); 748 } 749 m_cSPS.setScalingListFlag ( (m_useScalingListId == 0) ? 0 : 1 ); 750 m_cSPS.setUseDF( m_loopFilterOffsetInAPS ); 751 622 752 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 623 753 m_cSPS.setUseDMM( m_bUseDMM ); 624 754 #endif 625 #if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER626 m_cSPS.setUseDMM34( m_bUseDMM34 );627 #endif628 755 #if HHI_MPI 629 756 m_cSPS.setUseMVI( m_bUseMVI ); 630 757 #endif 631 758 632 m_cSPS.setCodedPictureBufferSize( m_uiCodedPictureStoreSize ); 633 } 634 635 #if CONSTRAINED_INTRA_PRED 759 if( m_isDepth ) 760 { 761 m_cSPS.initMultiviewSPSDepth ( m_viewId, m_iViewOrderIdx ); 762 #if DEPTH_MAP_GENERATION 763 m_cSPS.setPredDepthMapGeneration( m_viewId, true ); 764 #endif 765 #if HHI_INTER_VIEW_RESIDUAL_PRED 766 m_cSPS.setMultiviewResPredMode ( 0 ); 767 #endif 768 } 769 else 770 { 771 m_cSPS.initMultiviewSPS ( m_viewId, m_iViewOrderIdx, m_uiCamParPrecision, m_bCamParInSliceHeader, m_aaiCodedScale, m_aaiCodedOffset ); 772 if( m_viewId ) 773 { 774 #if DEPTH_MAP_GENERATION 775 #if HHI_INTER_VIEW_MOTION_PRED 776 m_cSPS.setPredDepthMapGeneration( m_viewId, false, m_uiPredDepthMapGeneration, m_uiMultiviewMvPredMode, m_uiPdmPrecision, m_aaiPdmScaleNomDelta, m_aaiPdmOffset ); 777 #else 778 m_cSPS.setPredDepthMapGeneration( m_viewId, false, m_uiPredDepthMapGeneration, 0, m_uiPdmPrecision, m_aaiPdmScaleNomDelta, m_aaiPdmOffset ); 779 #endif 780 #endif 781 #if HHI_INTER_VIEW_RESIDUAL_PRED 782 m_cSPS.setMultiviewResPredMode ( m_uiMultiviewResPredMode ); 783 #endif 784 } 785 else 786 { 787 #if DEPTH_MAP_GENERATION 788 m_cSPS.setPredDepthMapGeneration( m_viewId, false ); 789 #endif 790 #if HHI_INTER_VIEW_RESIDUAL_PRED 791 m_cSPS.setMultiviewResPredMode ( 0 ); 792 #endif 793 } 794 } 795 } 796 636 797 Void TEncTop::xInitPPS() 637 798 { 638 #if BITSTREAM_EXTRACTION639 m_cPPS.setLayerId( m_uiLayerId );640 #endif641 642 799 m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred ); 643 m_cPPS.setPPSId( ( m_uiViewId << 1 ) + ( m_bIsDepth ? 1 : 0 ) ); 644 m_cPPS.setSPSId( ( m_uiViewId << 1 ) + ( m_bIsDepth ? 1 : 0 ) ); 645 646 #ifdef WEIGHT_PRED 800 m_cPPS.setSliceGranularity(m_iSliceGranularity); 801 #if !H0566_TLA 802 if ( m_cSPS.getTemporalIdNestingFlag() ) 803 { 804 m_cPPS.setNumTLayerSwitchingFlags( 0 ); 805 for ( UInt i = 0; i < m_cSPS.getMaxTLayers() - 1; i++ ) 806 { 807 m_cPPS.setTLayerSwitchingFlag( i, true ); 808 } 809 } 810 else 811 { 812 m_cPPS.setNumTLayerSwitchingFlags( m_cSPS.getMaxTLayers() - 1 ); 813 for ( UInt i = 0; i < m_cPPS.getNumTLayerSwitchingFlags(); i++ ) 814 { 815 m_cPPS.setTLayerSwitchingFlag( i, m_abTLayerSwitchingFlag[i] ); 816 } 817 } 818 #endif 819 Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false; 820 821 #if LOSSLESS_CODING 822 #if H0736_AVC_STYLE_QP_RANGE 823 Int lowestQP = - m_cSPS.getQpBDOffsetY(); 824 #else 825 Int lowestQP = 0; 826 #endif 827 828 if(getUseLossless()) 829 { 830 if ((getMaxCuDQPDepth() == 0) && (getMaxDeltaQP() == 0 ) && (getQP() == lowestQP) ) 831 { 832 bUseDQP = false; 833 } 834 else 835 { 836 bUseDQP = true; 837 } 838 } 839 else 840 { 841 if(bUseDQP == false) 842 { 843 if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP()) 844 { 845 bUseDQP = true; 846 } 847 } 848 } 849 850 #else 851 if(bUseDQP == false) 852 { 853 if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP()) 854 { 855 bUseDQP = true; 856 } 857 } 858 #endif 859 860 if(bUseDQP) 861 { 862 m_cPPS.setUseDQP(true); 863 m_cPPS.setMaxCuDQPDepth( m_iMaxCuDQPDepth ); 864 m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) ); 865 } 866 else 867 { 868 m_cPPS.setUseDQP(false); 869 m_cPPS.setMaxCuDQPDepth( 0 ); 870 m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) ); 871 } 872 873 m_cPPS.setChromaQpOffset ( m_iChromaQpOffset ); 874 m_cPPS.setChromaQpOffset2nd( m_iChromaQpOffset2nd ); 875 876 m_cPPS.setEntropyCodingMode( 1 ); // In the PPS now, but also remains in slice header! 877 #if !WPP_SIMPLIFICATION 878 m_cPPS.setEntropyCodingSynchro(m_iWaveFrontSynchro); 879 m_cPPS.setCabacIstateReset(m_iWaveFrontFlush != 0); 880 #endif 881 m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams); 647 882 m_cPPS.setUseWP( m_bUseWeightPred ); 648 883 m_cPPS.setWPBiPredIdc( m_uiBiPredIdc ); 649 #endif 650 } 651 #endif 652 884 m_cPPS.setEnableTMVPFlag( m_bEnableTMVP ); 885 #if H0388 886 m_cPPS.setOutputFlagPresentFlag( false ); 887 #endif 888 #if MULTIBITS_DATA_HIDING 889 m_cPPS.setSignHideFlag(getSignHideFlag()); 890 m_cPPS.setTSIG(getTSIG()); 891 #endif 892 #if DBL_CONTROL 893 m_cPPS.setDeblockingFilterControlPresent (m_DeblockingFilterControlPresent ); 894 #endif 895 #if PARALLEL_MERGE 896 m_cPPS.setLog2ParallelMergeLevelMinus2 (LOG2_PARALLEL_MERGE_LEVEL_MINUS2); 897 #endif 898 #if CABAC_INIT_FLAG 899 m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG); 900 #endif 901 } 902 903 //Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file. 904 Void TEncTop::xInitRPS() 905 { 906 TComReferencePictureSet* rps; 907 908 m_RPSList.create(getGOPSize()+m_extraRPSs); 909 for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++) 910 { 911 GOPEntryMvc ge = getGOPEntry(i); 912 rps = m_RPSList.getReferencePictureSet(i); 913 rps->setNumberOfPictures(ge.m_numRefPics); 914 rps->setNumRefIdc(ge.m_numRefIdc); 915 Int numNeg = 0; 916 Int numPos = 0; 917 for( Int j = 0; j < ge.m_numRefPics; j++) 918 { 919 rps->setDeltaPOC(j,ge.m_referencePics[j]); 920 rps->setUsed(j,ge.m_usedByCurrPic[j]); 921 if(ge.m_referencePics[j]>0) 922 { 923 numPos++; 924 } 925 else 926 { 927 numNeg++; 928 } 929 } 930 rps->setNumberOfNegativePictures(numNeg); 931 rps->setNumberOfPositivePictures(numPos); 932 rps->setInterRPSPrediction(ge.m_interRPSPrediction); 933 if (ge.m_interRPSPrediction) 934 { 935 rps->setDeltaRIdxMinus1(ge.m_deltaRIdxMinus1); 936 rps->setDeltaRPS(ge.m_deltaRPS); 937 rps->setNumRefIdc(ge.m_numRefIdc); 938 for (Int j = 0; j < ge.m_numRefIdc; j++ ) 939 { 940 rps->setRefIdc(j, ge.m_refIdc[j]); 941 } 942 #if WRITE_BACK 943 // the folowing code overwrite the deltaPOC and Used by current values read from the config file with the ones 944 // computed from the RefIdc. This is not necessary if both are identical. Currently there is no check to see if they are identical. 945 numNeg = 0; 946 numPos = 0; 947 TComReferencePictureSet* RPSRef = m_RPSList.getReferencePictureSet(i-(ge.m_deltaRIdxMinus1+1)); 948 for (Int j = 0; j < ge.m_numRefIdc; j++ ) 949 { 950 if (ge.m_refIdc[j]) 951 { 952 Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0); 953 rps->setDeltaPOC((numNeg+numPos),deltaPOC); 954 rps->setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0); 955 if (deltaPOC<0) 956 { 957 numNeg++; 958 } 959 else 960 { 961 numPos++; 962 } 963 } 964 } 965 rps->setNumberOfNegativePictures(numNeg); 966 rps->setNumberOfPositivePictures(numPos); 967 rps->sortDeltaPOC(); 968 #endif 969 } 970 } 971 972 } 973 974 // This is a function that 975 // determines what Reference Picture Set to use 976 // for a specific slice (with POC = POCCurr) 977 Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid,TComList<TComPic*>& listPic ) 978 { 979 if( slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV ) 980 { 981 TComReferencePictureSet* rps = slice->getLocalRPS(); 982 rps->setNumberOfNegativePictures(0); 983 rps->setNumberOfPositivePictures(0); 984 rps->setNumberOfLongtermPictures(0); 985 rps->setNumberOfPictures(0); 986 slice->setRPS(rps); 987 } 988 else 989 { 990 slice->setRPSidx(GOPid); 991 992 for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) 993 { 994 if(m_uiIntraPeriod > 0) 995 { 996 if(POCCurr%m_uiIntraPeriod==m_GOPList[extraNum].m_POC) 997 { 998 slice->setRPSidx(extraNum); 999 } 1000 } 1001 else 1002 { 1003 if(POCCurr==m_GOPList[extraNum].m_POC) 1004 { 1005 slice->setRPSidx(extraNum); 1006 } 1007 } 1008 } 1009 1010 slice->setRPS(getRPSList()->getReferencePictureSet(slice->getRPSidx())); 1011 slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures()); 1012 } 1013 } 1014 1015 Void TEncTop::xInitSPSforInterViewRefs() 1016 { 1017 // base view 1018 if( getGOPEntry( MAX_GOP ).m_POC == -1 ) 1019 { 1020 m_cSPS.setNumberOfUsableInterViewRefs( 0 ); 1021 m_cSPS.setListsModificationPresentFlag( false ); 1022 return; 1023 } 1024 1025 Int numberUsableInterViewRefs = 0; 1026 for( Int i = 0; i < getGOPSize()+1 && numberUsableInterViewRefs < MAX_VIEW_NUM; i++ ) 1027 { 1028 GOPEntryMvc ge = ( i < getGOPSize() ) ? getGOPEntry( i ) : getGOPEntry( MAX_GOP ); 1029 for( Int j = 0; j < ge.m_numInterViewRefPics; j++ ) 1030 { 1031 // add ref view to list 1032 Bool onList = false; 1033 for( Int k = 0; k < numberUsableInterViewRefs; k++ ) 1034 { 1035 if( ge.m_interViewRefs[j] == m_cSPS.getUsableInterViewRef( k ) ) 1036 { 1037 onList = true; 1038 break; 1039 } 1040 } 1041 if( !onList ) 1042 { 1043 m_cSPS.setUsableInterViewRef( (UInt)numberUsableInterViewRefs, ge.m_interViewRefs[j] ); 1044 numberUsableInterViewRefs++; 1045 } 1046 } 1047 } 1048 m_cSPS.setNumberOfUsableInterViewRefs( numberUsableInterViewRefs ); 1049 1050 // sort inter view refs 1051 for( Int j = 1; j < m_cSPS.getNumberOfUsableInterViewRefs(); j++ ) 1052 { 1053 Int deltaViewId = m_cSPS.getUsableInterViewRef( j ); 1054 for( Int k = j-1; k >= 0; k-- ) 1055 { 1056 Int temp = m_cSPS.getUsableInterViewRef( k ); 1057 if( deltaViewId > temp ) 1058 { 1059 m_cSPS.setUsableInterViewRef( k+1, temp ); 1060 m_cSPS.setUsableInterViewRef( k, deltaViewId ); 1061 } 1062 } 1063 } 1064 1065 m_cSPS.setListsModificationPresentFlag( true ); 1066 } 1067 1068 Void TEncTop::xInitPPSforTiles() 1069 { 1070 m_cPPS.setColumnRowInfoPresent( m_iColumnRowInfoPresent ); 1071 m_cPPS.setUniformSpacingIdr( m_iUniformSpacingIdr ); 1072 #if !REMOVE_TILE_DEPENDENCE 1073 m_cPPS.setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr ); 1074 #endif 1075 m_cPPS.setNumColumnsMinus1( m_iNumColumnsMinus1 ); 1076 m_cPPS.setNumRowsMinus1( m_iNumRowsMinus1 ); 1077 if( m_iUniformSpacingIdr == 0 ) 1078 { 1079 m_cPPS.setColumnWidth( m_puiColumnWidth ); 1080 m_cPPS.setRowHeight( m_puiRowHeight ); 1081 } 1082 m_cPPS.setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag ); 1083 m_cPPS.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); 1084 1085 // # substreams is "per tile" when tiles are independent. 1086 if (m_iTileBoundaryIndependenceIdr && m_iWaveFrontSynchro) 1087 { 1088 m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams * (m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1)); 1089 } 1090 } 1091 1092 Void TEncCfg::xCheckGSParameters() 1093 { 1094 Int iWidthInCU = ( m_iSourceWidth%g_uiMaxCUWidth ) ? m_iSourceWidth/g_uiMaxCUWidth + 1 : m_iSourceWidth/g_uiMaxCUWidth; 1095 Int iHeightInCU = ( m_iSourceHeight%g_uiMaxCUHeight ) ? m_iSourceHeight/g_uiMaxCUHeight + 1 : m_iSourceHeight/g_uiMaxCUHeight; 1096 UInt uiCummulativeColumnWidth = 0; 1097 UInt uiCummulativeRowHeight = 0; 1098 1099 //check the column relative parameters 1100 if( m_iNumColumnsMinus1 >= (1<<(LOG2_MAX_NUM_COLUMNS_MINUS1+1)) ) 1101 { 1102 printf( "The number of columns is larger than the maximum allowed number of columns.\n" ); 1103 exit( EXIT_FAILURE ); 1104 } 1105 1106 if( m_iNumColumnsMinus1 >= iWidthInCU ) 1107 { 1108 printf( "The current picture can not have so many columns.\n" ); 1109 exit( EXIT_FAILURE ); 1110 } 1111 1112 if( m_iNumColumnsMinus1 && m_iUniformSpacingIdr==0 ) 1113 { 1114 for(Int i=0; i<m_iNumColumnsMinus1; i++) 1115 uiCummulativeColumnWidth += m_puiColumnWidth[i]; 1116 1117 if( uiCummulativeColumnWidth >= iWidthInCU ) 1118 { 1119 printf( "The width of the column is too large.\n" ); 1120 exit( EXIT_FAILURE ); 1121 } 1122 } 1123 1124 //check the row relative parameters 1125 if( m_iNumRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)) ) 1126 { 1127 printf( "The number of rows is larger than the maximum allowed number of rows.\n" ); 1128 exit( EXIT_FAILURE ); 1129 } 1130 1131 if( m_iNumRowsMinus1 >= iHeightInCU ) 1132 { 1133 printf( "The current picture can not have so many rows.\n" ); 1134 exit( EXIT_FAILURE ); 1135 } 1136 1137 if( m_iNumRowsMinus1 && m_iUniformSpacingIdr==0 ) 1138 { 1139 for(Int i=0; i<m_iNumRowsMinus1; i++) 1140 uiCummulativeRowHeight += m_puiRowHeight[i]; 1141 1142 if( uiCummulativeRowHeight >= iHeightInCU ) 1143 { 1144 printf( "The height of the row is too large.\n" ); 1145 exit( EXIT_FAILURE ); 1146 } 1147 } 1148 } 653 1149 654 1150 Void TEncTop::setTEncTopList(std::vector<TEncTop*>* pacTEncTopList ) 655 1151 { 656 assert(m_ uiViewId!=-1); // not to be set for single view coding1152 assert(m_viewId!=-1); // not to be set for single view coding 657 1153 658 1154 m_pacTEncTopList=pacTEncTopList; 659 1155 660 1156 } 661 662 1157 663 1158 Void TEncTop::printOutSummary(UInt uiNumAllPicCoded) … … 672 1167 673 1168 //-- all 674 if(m_ uiViewId==-1)1169 if(m_viewId==-1) 675 1170 printf( "\n\nSUMMARY --------------------------------------------------------\n" ); 676 1171 else { 677 if ( m_ bIsDepth )678 { 679 printf( "\n\nSUMMARY ---------------------------------------------- DEPTH %2d\n", m_ uiViewId );1172 if ( m_isDepth ) 1173 { 1174 printf( "\n\nSUMMARY ---------------------------------------------- DEPTH %2d\n", m_viewId ); 680 1175 } 681 1176 else 682 1177 { 683 printf( "\n\nSUMMARY ---------------------------------------------- VIDEO %2d\n", m_ uiViewId );1178 printf( "\n\nSUMMARY ---------------------------------------------- VIDEO %2d\n", m_viewId ); 684 1179 } 685 1180 }; … … 695 1190 m_cAnalyzeB.printOut('b'); 696 1191 697 #if _SUMMARY_OUT_ 698 m_cAnalyzeAll.printSummaryOut(); 699 #endif 700 #if _SUMMARY_PIC_ 701 m_cAnalyzeI.printSummary('I'); 702 m_cAnalyzeP.printSummary('P'); 703 m_cAnalyzeB.printSummary('B'); 704 #endif 705 } 706 707 Void TEncTop::xSetRefPics( TComPic* pcPic, RefPicList eRefPicList ) 708 { 709 assert(m_cSeqIter.getFrameDescriptor().getAllowedRelativeRefPocs( eRefPicList, pcPic->getViewIdx() ).size() == m_cSeqIter.getFrameDescriptor().getAllowedReferenceViewIdx( eRefPicList, pcPic->getViewIdx()).size()); 710 #if 1 711 // check if refPic is available 712 Int iNumberOfRefs = 0; 713 std::vector<Int> aiRefPocs ; 714 std::vector<Int> aiRefViews ; 715 716 for( Int i=0; i<(Int)m_cSeqIter.getFrameDescriptor().getAllowedRelativeRefPocs( eRefPicList, pcPic->getViewIdx() ).size(); i++ ) 717 { 718 Int iRefPoc = m_cSeqIter.getFrameDescriptor().getAllowedRelativeRefPocs( eRefPicList, pcPic->getViewIdx() )[i]+pcPic->getPOC() ; 719 Int iRefViewIdx = m_cSeqIter.getFrameDescriptor().getAllowedReferenceViewIdx( eRefPicList, pcPic->getViewIdx() )[i]; 720 Bool bFoundRefPic = false; 721 722 if( iRefPoc == pcPic->getPOC() ) // interview 723 { 724 assert( iRefViewIdx < (Int)m_uiViewId ); 725 aiRefPocs.push_back(iRefPoc); 726 aiRefViews.push_back(iRefViewIdx); 727 iNumberOfRefs++ ; 728 bFoundRefPic = true ; 729 continue; 730 } 731 else if ( iRefViewIdx < 0 ) // temporal 732 { 733 for( TComList<TComPic*>::iterator it = m_cListPic.begin(); it!=m_cListPic.end(); it++) 734 { 735 if( (*it)->getViewIdx() == pcPic->getViewIdx() && (*it)->getPOC() == iRefPoc && (*it)->getReconMark() ) 736 { 737 aiRefPocs.push_back(iRefPoc); 738 aiRefViews.push_back(m_uiViewId); 739 bFoundRefPic = true ; 740 iNumberOfRefs++ ; 741 break; 742 } 743 } 744 if( (iRefPoc < pcPic->getPOC()) && !bFoundRefPic ) 745 { 746 printf("\nInconsistence in GOP-String!"); 747 assert(0); 748 } 749 } 750 } 751 for ( Int i=0; i< iNumberOfRefs; i++) 752 { 753 pcPic->setRefViewIdx( aiRefViews[i], eRefPicList, i ); 754 pcPic->setRefPOC(aiRefPocs[i], eRefPicList, i ); 755 } 756 pcPic->setNumRefs( iNumberOfRefs, eRefPicList ); 757 #else 758 for( Int i=0; i<(Int)m_cSeqIter.getFrameDescriptor().getAllowedRelativeRefPocs( eRefPicList, pcPic->getViewIdx() ).size(); i++ ) 759 { 760 const int iRefViewIdx = m_cSeqIter.getFrameDescriptor().getAllowedReferenceViewIdx( eRefPicList, pcPic->getViewIdx() )[i]; 761 if( iRefViewIdx < 0 ) 762 { 763 // temporal reference from current view 764 pcPic->setRefViewIdx( m_iViewIdx, eRefPicList, i ); 765 } 766 else 767 { 768 pcPic->setRefViewIdx( iRefViewIdx, eRefPicList, i ); 769 } 770 pcPic->setRefPOC(m_cSeqIter.getFrameDescriptor().getAllowedRelativeRefPocs( eRefPicList, pcPic->getViewIdx() )[i]+pcPic->getPOC(), eRefPicList, i ); 771 } 772 pcPic->setNumRefs( m_cSeqIter.getFrameDescriptor().getAllowedRelativeRefPocs( eRefPicList, pcPic->getViewIdx() ).size(), eRefPicList ); 773 #endif 774 } 775 776 Void TEncTop::xCheckSliceType(TComPic* pcPic) 777 { 778 if( pcPic->getNumRefs(REF_PIC_LIST_0) == 0 && pcPic->getNumRefs(REF_PIC_LIST_1) == 0 && pcPic->getSliceType() == I_SLICE ) 779 { 780 return ; 781 } 782 if( pcPic->getNumRefs(REF_PIC_LIST_0) != 0 && pcPic->getNumRefs(REF_PIC_LIST_1) == 0 && pcPic->getSliceType() == P_SLICE ) 783 { 784 return ; 785 } 786 if( pcPic->getNumRefs(REF_PIC_LIST_0) != 0 && pcPic->getNumRefs(REF_PIC_LIST_1) != 0 && pcPic->getSliceType() == B_SLICE ) 787 { 788 return ; 789 } 790 if( pcPic->getNumRefs(REF_PIC_LIST_0) == 0 && pcPic->getNumRefs(REF_PIC_LIST_1) == 0 ) 791 { 792 pcPic->setSliceType(I_SLICE) ; 793 return; 794 } 795 if( pcPic->getNumRefs(REF_PIC_LIST_0) != 0 && pcPic->getNumRefs(REF_PIC_LIST_1) == 0 ) 796 { 797 pcPic->setSliceType(P_SLICE) ; 798 return; 799 } 800 801 assert(0); 802 } 803 804 805 Void TEncTop::xSetPicProperties(TComPic* pcPic) 806 { 807 pcPic->setSliceType( m_cSeqIter.getFrameDescriptor().getSliceType(m_uiViewId) ); 808 pcPic->setReferenced( m_cSeqIter.getFrameDescriptor().getStoreForRef(m_uiViewId) ); 809 pcPic->setColDir( m_cSeqIter.getFrameDescriptor().getColDir() ) ; 810 const Bool bQpChangePointPassed = m_iFrameNumInCodingOrder++ >= getQpChangeFrame(); 811 const Int iQpChangeOffset = bQpChangePointPassed ? ( m_bIsDepth ? getQpChangeOffsetDepth() : getQpChangeOffsetVideo() ) : 0; 812 pcPic->setQP(max(MIN_QP,min(MAX_QP, m_iQP+ m_aiTLayerQPOffset[m_cSeqIter.getFrameDescriptor().getTEncSeqStructureLayer(m_uiViewId)] + iQpChangeOffset )) ); 813 pcPic->setViewIdx( m_uiViewId ); 814 #if SONY_COLPIC_AVAILABILITY 815 pcPic->setViewOrderIdx(m_iViewOrderIdx); 816 #endif 817 #if 0 818 pcPic->setNumRefs(0, REF_PIC_LIST_0); 819 pcPic->setNumRefs(0, REF_PIC_LIST_1); 820 821 822 if( m_cSeqIter.getFrameDescriptor().getSliceType(m_iViewIdx)== P_SLICE || m_cSeqIter.getFrameDescriptor().getSliceType(m_iViewIdx)== B_SLICE) 823 { 824 xSetRefPics( pcPic, REF_PIC_LIST_0 ); 825 } 826 if( m_cSeqIter.getFrameDescriptor().getSliceType(m_iViewIdx)== B_SLICE) 827 { 828 xSetRefPics( pcPic, REF_PIC_LIST_1 ); 829 } 830 #else 831 xSetRefPics( pcPic, REF_PIC_LIST_0 ); 832 xSetRefPics( pcPic, REF_PIC_LIST_1 ); 833 xCheckSliceType( pcPic ); 834 #endif 835 836 pcPic->setScaleOffset( m_aaiCodedScale, m_aaiCodedOffset ); 837 } 1192 // m_cAnalyzeAll.printSummaryOut(); 1193 // m_cAnalyzeI.printSummary('I'); 1194 // m_cAnalyzeP.printSummary('P'); 1195 // m_cAnalyzeB.printSummary('B'); 1196 } 1197 1198 //! \}
Note: See TracChangeset for help on using the changeset viewer.