Changeset 798 in SHVCSoftware for branches/SHM-6-dev/source/Lib/TLibEncoder
- Timestamp:
- 10 Jun 2014, 01:10:15 (11 years ago)
- Location:
- branches/SHM-6-dev/source/Lib/TLibEncoder
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-6-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
r796 r798 998 998 { 999 999 WRITE_UVLC( vps->getNumAddLayerSets(), "num_add_layer_sets" ); 1000 for ( Inti = 0; i < vps->getNumAddLayerSets(); i++)1001 { 1002 for ( Intj = 1; j < vps->getNumIndependentLayers(); j++)1000 for (i = 0; i < vps->getNumAddLayerSets(); i++) 1001 { 1002 for (j = 1; j < vps->getNumIndependentLayers(); j++) 1003 1003 { 1004 1004 int len = 1; … … 1828 1828 } 1829 1829 #else 1830 #if POC_RESET_IDC_ENCODER 1831 Int picOrderCntLSB; 1832 if( pcSlice->getPocResetIdc() == 2 ) // i.e. the LSB is reset 1833 { 1834 picOrderCntLSB = pcSlice->getPicOrderCntLsb(); // This will be the LSB value w.r.t to the previous POC reset period. 1835 } 1836 else 1837 { 1838 picOrderCntLSB = (pcSlice->getPOC() + (1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 1839 } 1840 #else 1830 1841 Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 1842 #endif 1831 1843 #endif 1832 1844 WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb"); … … 2300 2312 { 2301 2313 Int tmpBitsBeforeWriting = getNumberOfWrittenBits(); 2314 Int maxPocLsb = 1 << slice->getSPS()->getBitsForPOC(); 2302 2315 if(slice->getPPS()->getSliceHeaderExtensionPresentFlag()) 2303 2316 { … … 2342 2355 { 2343 2356 UInt lengthVal = 1; 2344 UInt tempVal = slice->getPocMsbVal() + 1;2357 UInt tempVal = (slice->getPocMsbVal() / maxPocLsb) + 1; 2345 2358 assert ( tempVal ); 2346 2359 while( 1 != tempVal ) … … 2379 2392 if( slice->getPocMsbValPresentFlag() ) 2380 2393 { 2381 WRITE_UVLC( slice->getPocMsbVal(), "poc_msb_val" ); 2394 assert( slice->getPocMsbVal() % maxPocLsb == 0 ); 2395 WRITE_UVLC( slice->getPocMsbVal() / maxPocLsb, "poc_msb_val" ); 2382 2396 } 2383 2397 for (Int i = 0; i < shExtnAdditionalBits; i++) -
branches/SHM-6-dev/source/Lib/TLibEncoder/TEncGOP.cpp
r780 r798 92 92 m_bRefreshPending = 0; 93 93 m_pocCRA = 0; 94 #if POC_RESET_IDC_ENCODER 95 m_pocCraWithoutReset = 0; 96 m_associatedIrapPocBeforeReset = 0; 97 #endif 94 98 m_numLongTermRefPicSPS = 0; 95 99 ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps)); … … 108 112 m_temp = NULL; 109 113 m_pColorMappedPic = NULL; 114 #endif 115 #if POC_RESET_IDC_ENCODER 116 m_lastPocPeriodId = -1; 110 117 #endif 111 118 #endif //SVC_EXTENSION … … 903 910 } 904 911 #endif 912 #if POC_RESET_IDC_ENCODER 913 pcSlice->setPocValueBeforeReset( pocCurr ); 914 // Check if the current picture is to be assigned as a reset picture 915 determinePocResetIdc(pocCurr, pcSlice); 916 917 // If reset, do the following steps: 918 if( pcSlice->getPocResetIdc() ) 919 { 920 updatePocValuesOfPics(pocCurr, pcSlice); 921 } 922 else 923 { 924 // Check the base layer picture is IDR. If so, just set current POC equal to 0 (alignment of POC) 925 if( ( m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == 2) && ( pocCurr % m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshInterval() == 0 ) ) 926 { 927 m_pcEncTop->setPocAdjustmentValue( pocCurr ); 928 } 929 // else 930 { 931 // Just subtract POC by the current cumulative POC delta 932 pcSlice->setPOC( pocCurr - m_pcEncTop->getPocAdjustmentValue() ); 933 } 934 935 Int maxPocLsb = 1 << pcSlice->getSPS()->getBitsForPOC(); 936 pcSlice->setPocMsbVal( pcSlice->getPOC() - ( pcSlice->getPOC() & (maxPocLsb-1) ) ); 937 } 938 // Update the POC of current picture, pictures in the DPB, including references inside the reference pictures 939 940 #endif 941 905 942 #if O0149_CROSS_LAYER_BLA_FLAG 906 943 if( m_layerId == 0 && (getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_N_LP) ) … … 1225 1262 else 1226 1263 { 1264 #if ALIGN_IRAP_BUGFIX 1265 #if 0 1227 1266 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_CRA); 1267 #endif 1268 #endif 1228 1269 } 1229 1270 } … … 1272 1313 { 1273 1314 m_associatedIRAPType = pcSlice->getNalUnitType(); 1315 #if POC_RESET_IDC_ENCODER 1316 m_associatedIRAPPOC = pcSlice->getPOC(); 1317 m_associatedIrapPocBeforeReset = pocCurr; 1318 #else 1274 1319 m_associatedIRAPPOC = pocCurr; 1320 #endif 1275 1321 } 1276 1322 pcSlice->setAssociatedIRAPType(m_associatedIRAPType); 1277 1323 pcSlice->setAssociatedIRAPPOC(m_associatedIRAPPOC); 1324 pcSlice->setAssociatedIrapPocBeforeReset(m_associatedIrapPocBeforeReset); 1278 1325 #endif 1279 1326 #endif … … 1283 1330 #else 1284 1331 pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic); 1332 #endif 1333 #if POC_RESET_IDC_ENCODER 1334 // m_pocCRA may have been update here; update m_pocCraWithoutReset 1335 m_pocCraWithoutReset = m_pocCRA + m_pcEncTop->getPocAdjustmentValue(); 1285 1336 #endif 1286 1337 m_pcEncTop->selectReferencePictureSet(pcSlice, pocCurr, iGOPid); … … 1320 1371 #endif 1321 1372 #if ALIGNED_BUMPING 1373 #if POC_RESET_IDC_ENCODER 1374 pcSlice->checkLeadingPictureRestrictions(rcListPic, true); 1375 #else 1322 1376 pcSlice->checkLeadingPictureRestrictions(rcListPic); 1377 #endif 1323 1378 #endif 1324 1379 pcSlice->applyReferencePictureSet(rcListPic, pcSlice->getRPS()); … … 1513 1568 if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() ) 1514 1569 { 1515 #if POC_RESET_FLAG 1570 #if POC_RESET_FLAG || POC_RESET_IDC_ENCODER 1516 1571 if ( pocCurr > 0 && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL()) 1517 1572 #else … … 1853 1908 1854 1909 Int sliceQP = m_pcCfg->getInitialQP(); 1855 #if POC_RESET_FLAG 1910 #if POC_RESET_FLAG || POC_RESET_IDC_ENCODER 1856 1911 if ( ( pocCurr == 0 && m_pcCfg->getInitialQP() > 0 ) || ( frameLevel == 0 && m_pcCfg->getForceIntraQP() ) ) // QP is specified 1857 1912 #else … … 2385 2440 } 2386 2441 pictureTimingSEI.m_auCpbRemovalDelay = std::min<Int>(std::max<Int>(1, m_totalCoded - m_lastBPSEI), static_cast<Int>(pow(2, static_cast<double>(pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getCpbRemovalDelayLengthMinus1()+1)))); // Syntax element signalled as minus, hence the . 2387 #if POC_RESET_FLAG 2442 #if POC_RESET_FLAG || POC_RESET_IDC_ENCODER 2388 2443 pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(pcSlice->getSPS()->getMaxTLayers()-1) + pocCurr - m_totalCoded; 2389 2444 #else … … 2513 2568 SEIRecoveryPoint sei_recovery_point; 2514 2569 sei_recovery_point.m_recoveryPocCnt = 0; 2515 #if POC_RESET_FLAG 2570 #if POC_RESET_FLAG || POC_RESET_IDC_ENCODER 2516 2571 sei_recovery_point.m_exactMatchingFlag = ( pocCurr == 0 ) ? (true) : (false); 2517 2572 #else … … 3268 3323 #endif 3269 3324 } 3325 3326 #if POC_RESET_IDC_ENCODER 3327 Void TEncGOP::determinePocResetIdc(Int const pocCurr, TComSlice *const slice) 3328 { 3329 // If one picture in the AU is IDR, and another picture is not IDR, set the poc_reset_idc to 1 or 2 3330 // If BL picture in the AU is IDR, and another picture is not IDR, set the poc_reset_idc to 2 3331 // If BL picture is IRAP, and another picture is non-IRAP, then the poc_reset_idc is equal to 1 or 2. 3332 if( slice->getSliceIdx() == 0 ) // First slice - compute, copy for other slices 3333 { 3334 Int needReset = false; 3335 Int resetDueToBL = false; 3336 if( slice->getVPS()->getMaxLayers() > 1 ) 3337 { 3338 // If IRAP is refreshed in this access unit for base layer 3339 if( (m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == 1 || m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == 2) 3340 && ( pocCurr % m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshInterval() == 0 ) 3341 ) 3342 { 3343 // Check if the IRAP refresh interval of any layer does not match that of the base layer 3344 for(Int i = 1; i < slice->getVPS()->getMaxLayers(); i++) 3345 { 3346 Bool refreshIntervalFlag = ( pocCurr % m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshInterval() == 0 ); 3347 Bool refreshTypeFlag = ( m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshType() ); 3348 if( !(refreshIntervalFlag && refreshTypeFlag) ) 3349 { 3350 needReset = true; 3351 resetDueToBL = true; 3352 break; 3353 } 3354 } 3355 } 3356 } 3357 3358 if( !needReset )// No need reset due to base layer IRAP 3359 { 3360 // Check if EL IDRs results in POC Reset 3361 for(Int i = 1; i < slice->getVPS()->getMaxLayers() && !needReset; i++) 3362 { 3363 Bool idrFlag = ( (m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshType() == 2) 3364 && ( pocCurr % m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshInterval() == 0 ) 3365 ); 3366 for(Int j = 0; j < slice->getVPS()->getMaxLayers(); j++) 3367 { 3368 if( j == i ) 3369 { 3370 continue; 3371 } 3372 Bool idrOtherPicFlag = ( (m_ppcTEncTop[j]->getGOPEncoder()->getIntraRefreshType() == 2) 3373 && ( pocCurr % m_ppcTEncTop[j]->getGOPEncoder()->getIntraRefreshInterval() == 0 ) 3374 ); 3375 3376 if( idrFlag != idrOtherPicFlag ) 3377 { 3378 needReset = true; 3379 break; 3380 } 3381 } 3382 } 3383 } 3384 if( needReset ) 3385 { 3386 if( m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == 2 ) // BL IDR refresh, assuming BL picture present 3387 { 3388 if( resetDueToBL ) 3389 { 3390 slice->setPocResetIdc( 2 ); // Full reset needed 3391 } 3392 else 3393 { 3394 slice->setPocResetIdc( 1 ); // Due to IDR in EL 3395 } 3396 } 3397 else 3398 { 3399 slice->setPocResetIdc( 1 ); // Only MSB reset 3400 } 3401 3402 // Start a new POC reset period 3403 if (m_layerId == 0) // Assuming BL picture is always present at encoder; for other AU structures, need to change this 3404 { 3405 Int periodId = rand() % 64; 3406 m_lastPocPeriodId = (periodId == m_lastPocPeriodId) ? (periodId + 1) % 64 : periodId ; 3407 } 3408 else 3409 { 3410 m_lastPocPeriodId = m_ppcTEncTop[0]->getGOPEncoder()->getLastPocPeriodId(); 3411 } 3412 slice->setPocResetPeriodId(m_lastPocPeriodId); 3413 } 3414 else 3415 { 3416 slice->setPocResetIdc( 0 ); 3417 } 3418 } 3419 } 3420 3421 Void TEncGOP::updatePocValuesOfPics(Int const pocCurr, TComSlice *const slice) 3422 { 3423 3424 Int pocAdjustValue = pocCurr - m_pcEncTop->getPocAdjustmentValue(); 3425 3426 // New POC reset period 3427 Int maxPocLsb, pocLsbVal, pocMsbDelta, pocLsbDelta, deltaPocVal; 3428 3429 maxPocLsb = 1 << slice->getSPS()->getBitsForPOC(); 3430 pocLsbVal = (slice->getPocResetIdc() == 3) 3431 ? slice->getPocLsbVal() 3432 : pocAdjustValue % maxPocLsb; 3433 pocMsbDelta = pocAdjustValue - pocLsbVal; 3434 pocLsbDelta = (slice->getPocResetIdc() == 2 || ( slice->getPocResetIdc() == 3 && slice->getFullPocResetFlag() )) 3435 ? pocLsbVal 3436 : 0; 3437 deltaPocVal = pocMsbDelta + pocLsbDelta; 3438 3439 // Decrement value of associatedIrapPoc of the TEncGop object 3440 this->m_associatedIRAPPOC -= deltaPocVal; 3441 3442 // Decrememnt the value of m_pocCRA 3443 this->m_pocCRA -= deltaPocVal; 3444 3445 // Iterate through all pictures in the DPB 3446 TComList<TComPic*>::iterator iterPic = getListPic()->begin(); 3447 while( iterPic != getListPic()->end() ) 3448 { 3449 TComPic *dpbPic = *iterPic; 3450 3451 if( dpbPic->getReconMark() ) 3452 { 3453 for(Int i = dpbPic->getNumAllocatedSlice() - 1; i >= 0; i--) 3454 { 3455 TComSlice *dpbPicSlice = dpbPic->getSlice( i ); 3456 TComReferencePictureSet *dpbPicRps = dpbPicSlice->getRPS(); 3457 3458 // Decrement POC of slice 3459 dpbPicSlice->setPOC( dpbPicSlice->getPOC() - deltaPocVal ); 3460 3461 // Decrement POC value stored in the RPS of each such slice 3462 for( Int j = dpbPicRps->getNumberOfPictures() - 1; j >= 0; j-- ) 3463 { 3464 dpbPicRps->setPOC( j, dpbPicRps->getPOC(j) - deltaPocVal ); 3465 } 3466 3467 // Decrement value of refPOC 3468 dpbPicSlice->decrementRefPocValues( deltaPocVal ); 3469 3470 // Update value of associatedIrapPoc of each slice 3471 dpbPicSlice->setAssociatedIRAPPOC( dpbPicSlice->getAssociatedIRAPPOC() - deltaPocVal ); 3472 } 3473 } 3474 iterPic++; 3475 } 3476 3477 // Actual POC value before reset 3478 Int adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue(); 3479 3480 // Set MSB value before reset 3481 Int tempLsbVal = adjustedPocValue & (maxPocLsb - 1); 3482 slice->setPocMsbVal( adjustedPocValue - tempLsbVal); 3483 3484 // Set LSB value before reset - this is needed in the case of resetIdc = 2 3485 slice->setPicOrderCntLsb( tempLsbVal ); 3486 3487 // Cumulative delta 3488 m_pcEncTop->setPocAdjustmentValue( m_pcEncTop->getPocAdjustmentValue() + deltaPocVal ); 3489 3490 // New LSB value, after reset 3491 adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue(); 3492 Int newLsbVal = adjustedPocValue & (maxPocLsb - 1); 3493 3494 // Set value of POC current picture after RESET 3495 if( slice->getPocResetIdc() == 1 ) 3496 { 3497 slice->setPOC( newLsbVal ); 3498 } 3499 else if( slice->getPocResetIdc() == 2 ) 3500 { 3501 slice->setPOC( 0 ); 3502 } 3503 else if( slice->getPocResetIdc() == 3 ) 3504 { 3505 Int picOrderCntMsb = slice->getCurrMsb( newLsbVal, 3506 slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal(), 3507 0, 3508 maxPocLsb ); 3509 slice->setPOC( picOrderCntMsb + newLsbVal ); 3510 } 3511 else 3512 { 3513 assert(0); 3514 } 3515 } 3516 #endif 3517 3270 3518 3271 3519 #if !SVC_EXTENSION … … 3716 3964 if( pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->isILR(m_layerId) ) 3717 3965 { 3966 #if POC_RESET_IDC_ENCODER 3967 printf( "%d(%d)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() ); 3968 #else 3718 3969 printf( "%d(%d)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR(), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() ); 3970 #endif 3719 3971 } 3720 3972 else 3721 3973 { 3974 #if POC_RESET_IDC_ENCODER 3975 printf ("%d", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)); 3976 #else 3722 3977 printf ("%d", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR()); 3978 #endif 3723 3979 } 3724 3980 #endif … … 3947 4203 } 3948 4204 } 4205 4206 #if POC_RESET_IDC_ENCODER 4207 if(m_pocCraWithoutReset > 0 && this->m_associatedIRAPType == NAL_UNIT_CODED_SLICE_CRA) 4208 { 4209 if(pocCurr < m_pocCraWithoutReset) 4210 #else 3949 4211 if(m_pocCRA>0) 3950 4212 { 3951 4213 if(pocCurr<m_pocCRA) 4214 #endif 3952 4215 { 3953 4216 // All leading pictures are being marked as TFD pictures here since current encoder uses all -
branches/SHM-6-dev/source/Lib/TLibEncoder/TEncGOP.h
r776 r798 113 113 Bool m_bRefreshPending; 114 114 Int m_pocCRA; 115 #if POC_RESET_IDC_ENCODER 116 Int m_pocCraWithoutReset; 117 Int m_associatedIrapPocBeforeReset; 118 #endif 115 119 std::vector<Int> m_storedStartCUAddrForEncodingSlice; 116 120 std::vector<Int> m_storedStartCUAddrForEncodingSliceSegment; … … 152 156 Int **m_temp; 153 157 #endif 158 #if POC_RESET_IDC_ENCODER 159 Int m_lastPocPeriodId; 160 #endif 154 161 #endif 155 162 … … 170 177 #else 171 178 Void compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff ); 179 #endif 180 #if POC_RESET_IDC_ENCODER 181 Void determinePocResetIdc( Int const pocCurr, TComSlice *const slice); 182 Int getIntraRefreshInterval() { return m_pcCfg->getIntraPeriod(); } 183 Int getIntraRefreshType() { return m_pcCfg->getDecodingRefreshType(); } 184 // Int getIntraRefreshInterval () { return (m_pcCfg) ? m_pcCfg->getIntraPeriod() : 0; } 185 Int getLastPocPeriodId() { return m_lastPocPeriodId; } 186 Void setLastPocPeriodId(Int x) { m_lastPocPeriodId = x; } 187 Void updatePocValuesOfPics( Int const pocCurr, TComSlice *const slice); 172 188 #endif 173 189 Void xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect); -
branches/SHM-6-dev/source/Lib/TLibEncoder/TEncTop.cpp
r797 r798 89 89 #endif 90 90 m_numScaledRefLayerOffsets = 0; 91 #if POC_RESET_FLAG 91 #if POC_RESET_FLAG || POC_RESET_IDC_ENCODER 92 92 m_pocAdjustmentValue = 0; 93 93 #endif … … 1208 1208 m_cPPS.setCGSFlag( m_nCGSFlag ); 1209 1209 #endif 1210 #if POC_RESET_IDC_ENCODER 1211 m_cPPS.setPocResetInfoPresentFlag( true ); 1212 m_cPPS.setExtensionFlag( true ); 1213 m_cPPS.setSliceHeaderExtensionPresentFlag( true ); 1214 #endif 1210 1215 #endif //SVC_EXTENSION 1211 1216 } -
branches/SHM-6-dev/source/Lib/TLibEncoder/TEncTop.h
r778 r798 142 142 Bool m_vertPhasePositionEnableFlag[MAX_LAYERS]; 143 143 #endif 144 #if POC_RESET_FLAG 144 #if POC_RESET_FLAG || POC_RESET_IDC_ENCODER 145 145 Int m_pocAdjustmentValue; 146 146 #endif … … 257 257 TEncTop* getRefLayerEnc(UInt refLayerIdc); 258 258 #endif 259 #if POC_RESET_FLAG 259 #if POC_RESET_FLAG || POC_RESET_IDC_ENCODER 260 260 Int getPocAdjustmentValue() { return m_pocAdjustmentValue;} 261 261 Void setPocAdjustmentValue(Int x) { m_pocAdjustmentValue = x; }
Note: See TracChangeset for help on using the changeset viewer.