Changeset 431 in SHVCSoftware for branches/SHM-3.1-dev/source/Lib/TLibEncoder
- Timestamp:
- 11 Oct 2013, 05:54:02 (11 years ago)
- Location:
- branches/SHM-3.1-dev/source/Lib/TLibEncoder
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncAnalyze.cpp
r313 r431 57 57 #endif 58 58 59 TEncAnalyze m_gcAnalyzeAll_in; 59 60 //! \} -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncAnalyze.h
r313 r431 131 131 fclose(pFile); 132 132 } 133 134 Void printOutInterlaced ( Char cDelim, Double bits ) 135 { 136 Double dFps = m_dFrmRate; //--CFG_KDY 137 Double dScale = dFps / 1000 / (Double)m_uiNumPic; 138 139 printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); 140 //printf( "\t------------ " " ----------" " -------- " " -------- " " --------\n" ); 141 printf( "\t %8d %c" "%12.4lf " "%8.4lf " "%8.4lf " "%8.4lf\n", 142 getNumPic(), cDelim, 143 bits * dScale, 144 getPsnrY() / (Double)getNumPic(), 145 getPsnrU() / (Double)getNumPic(), 146 getPsnrV() / (Double)getNumPic() ); 147 } 148 149 Void printSummaryOutInterlaced (Int bits) 150 { 151 FILE* pFile = fopen ("summaryTotal.txt", "at"); 152 Double dFps = m_dFrmRate; //--CFG_KDY 153 Double dScale = dFps / 1000 / (Double)m_uiNumPic; 154 155 fprintf(pFile, "%f\t %f\t %f\t %f\n", bits * dScale, 156 getPsnrY() / (Double)getNumPic(), 157 getPsnrU() / (Double)getNumPic(), 158 getPsnrV() / (Double)getNumPic() ); 159 fclose(pFile); 160 } 133 161 134 162 Void printSummary(Char ch) … … 178 206 #endif 179 207 208 extern TEncAnalyze m_gcAnalyzeAll_in; 180 209 //! \} 181 210 -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
r427 r431 1281 1281 if( !pcSlice->getPocResetFlag() ) 1282 1282 { 1283 picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) %(1<<pcSlice->getSPS()->getBitsForPOC());1283 picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 1284 1284 } 1285 1285 else 1286 1286 { 1287 picOrderCntLSB = (pcSlice->getPocValueBeforeReset()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) %(1<<pcSlice->getSPS()->getBitsForPOC());1288 } 1289 #else 1290 Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) %(1<<pcSlice->getSPS()->getBitsForPOC());1287 picOrderCntLSB = (pcSlice->getPocValueBeforeReset()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 1288 } 1289 #else 1290 Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 1291 1291 #endif 1292 1292 WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb"); … … 2142 2142 { 2143 2143 // Bool state = true, state2 = false; 2144 Int lsb = ltrpPOC % (1<<pcSlice->getSPS()->getBitsForPOC());2144 Int lsb = ltrpPOC & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 2145 2145 for (Int k = 0; k < pcSlice->getSPS()->getNumLongTermRefPicSPS(); k++) 2146 2146 { -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncCu.cpp
r389 r431 379 379 m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() ); 380 380 381 // variables for fast encoder decision382 Bool bEarlySkip = false;383 Bool bTrySplit = true;384 Double fRD_Skip = MAX_DOUBLE;385 386 381 // variable for Early CU determination 387 382 Bool bSubBranch = true; … … 390 385 Bool doNotBlockPu = true; 391 386 Bool earlyDetectionSkipMode = false; 392 393 Bool bTrySplitDQP = true;394 395 static Double afCost[ MAX_CU_DEPTH ];396 static Int aiNum [ MAX_CU_DEPTH ];397 398 if ( rpcBestCU->getAddr() == 0 )399 {400 ::memset( afCost, 0, sizeof( afCost ) );401 ::memset( aiNum, 0, sizeof( aiNum ) );402 }403 387 404 388 Bool bBoundary = false; … … 471 455 if (rpcBestCU->getLayerId() > 0) 472 456 { 473 if(pcSlice->getSliceType() == P_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx()) 474 testInter = false; 475 if(pcSlice->getSliceType() == B_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == pcSlice->getActiveNumILRRefIdx()) 476 testInter = false; 457 if(pcSlice->getSliceType() == P_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx()) 458 { 459 testInter = false; 460 } 461 if(pcSlice->getSliceType() == B_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == pcSlice->getActiveNumILRRefIdx()) 462 { 463 testInter = false; 464 } 477 465 #if M0457_IL_SAMPLE_PRED_ONLY_FLAG 478 if( pcSlice->getInterLayerSamplePredOnlyFlag() ) 479 testInter = false; 466 if( pcSlice->getInterLayerSamplePredOnlyFlag() ) 467 { 468 testInter = false; 469 } 480 470 #endif 481 471 } … … 487 477 iQP = lowestQP; 488 478 } 489 // variables for fast encoder decision490 bEarlySkip = false;491 bTrySplit = true;492 fRD_Skip = MAX_DOUBLE;493 479 494 480 rpcTempCU->initEstData( uiDepth, iQP ); … … 509 495 xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode );//by Merge for inter_2Nx2N 510 496 rpcTempCU->initEstData( uiDepth, iQP ); 511 512 // fast encoder decision for early skip 513 if ( m_pcEncCfg->getUseFastEnc() ) 514 { 515 Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ]; 516 if ( aiNum [ iIdx ] > 5 && fRD_Skip < EARLY_SKIP_THRES*afCost[ iIdx ]/aiNum[ iIdx ] ) 517 { 518 bEarlySkip = true; 519 bTrySplit = false; 520 } 521 } 497 522 498 #if (ENCODER_FAST_MODE == 2) 523 499 if (testInter) 524 500 { 525 501 #endif 526 527 502 if(!m_pcEncCfg->getUseEarlySkipDetection()) 528 503 { 529 504 // 2Nx2N, NxN 530 if ( !bEarlySkip ) 505 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); rpcTempCU->initEstData( uiDepth, iQP ); 506 if(m_pcEncCfg->getUseCbfFastMode()) 531 507 { 532 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); rpcTempCU->initEstData( uiDepth, iQP ); 533 if(m_pcEncCfg->getUseCbfFastMode()) 534 { 535 doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; 536 } 508 doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; 537 509 } 538 510 } 539 511 #if (ENCODER_FAST_MODE == 2) 540 } 541 #endif 542 543 } 544 545 if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) 546 { 547 if(iQP == iBaseQP) 548 { 549 bTrySplitDQP = bTrySplit; 550 } 551 } 552 else 553 { 554 bTrySplitDQP = bTrySplit; 555 } 512 } 513 #endif 514 } 515 556 516 if (isAddLowestQP && (iQP == lowestQP)) 557 517 { … … 580 540 // do inter modes, NxN, 2NxN, and Nx2N 581 541 #if (ENCODER_FAST_MODE) 582 if( rpcBestCU->getSlice()->getSliceType() != I_SLICE && testInter )542 if( rpcBestCU->getSlice()->getSliceType() != I_SLICE && testInter ) 583 543 #else 584 544 if( rpcBestCU->getSlice()->getSliceType() != I_SLICE ) … … 586 546 { 587 547 // 2Nx2N, NxN 588 if ( !bEarlySkip)548 if(!( (rpcBestCU->getWidth(0)==8) && (rpcBestCU->getHeight(0)==8) )) 589 549 { 590 if( !( (rpcBestCU->getWidth(0)==8) && (rpcBestCU->getHeight(0)==8) ))550 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && doNotBlockPu) 591 551 { 592 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && doNotBlockPu) 593 { 594 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN ); 595 rpcTempCU->initEstData( uiDepth, iQP ); 596 } 552 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN ); 553 rpcTempCU->initEstData( uiDepth, iQP ); 597 554 } 598 555 } … … 734 691 735 692 // do normal intra modes 736 if ( !bEarlySkip )737 {738 693 // speedup for inter frames 739 694 #if (ENCODER_FAST_MODE) … … 761 716 } 762 717 } 763 }764 718 765 719 // test PCM … … 803 757 rpcBestCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() ); 804 758 805 // accumulate statistics for early skip806 if ( m_pcEncCfg->getUseFastEnc() )807 {808 if ( rpcBestCU->isSkipped(0) )809 {810 Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ];811 afCost[ iIdx ] += rpcBestCU->getTotalCost();812 aiNum [ iIdx ] ++;813 }814 }815 816 759 // Early CU determination 817 760 if( m_pcEncCfg->getUseEarlyCU() && rpcBestCU->isSkipped(0) ) … … 896 839 897 840 // further split 898 if( bSubBranch && bTrySplitDQP &&uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth )841 if( bSubBranch && uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) 899 842 { 900 843 UChar uhNextDepth = uiDepth+1; -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp
r429 r431 375 375 // ==================================================================================================================== 376 376 #if SVC_EXTENSION 377 Void TEncGOP::compressGOP( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP )378 #else 379 Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP )377 Void TEncGOP::compressGOP( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff) 378 #else 379 Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff) 380 380 #endif 381 381 { … … 390 390 TComOutputBitstream* pcSubstreamsOut = NULL; 391 391 392 xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut );392 xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut, isField ); 393 393 394 394 m_iNumPicCoded = 0; … … 463 463 464 464 /////////////////////////////////////////////////////////////////////////////////////////////////// Initial to start encoding 465 Int pocCurr = iPOCLast -iNumPicRcvd+ m_pcCfg->getGOPEntry(iGOPid).m_POC; 466 Int iTimeOffset = m_pcCfg->getGOPEntry(iGOPid).m_POC; 467 if(iPOCLast == 0) 465 Int iTimeOffset; 466 Int pocCurr; 467 468 if(iPOCLast == 0) //case first frame or first top field 468 469 { 469 470 pocCurr=0; 470 471 iTimeOffset = 1; 471 472 } 473 else if(iPOCLast == 1 && isField) //case first bottom field, just like the first frame, the poc computation is not right anymore, we set the right value 474 { 475 pocCurr = 1; 476 iTimeOffset = 1; 477 } 478 else 479 { 480 pocCurr = iPOCLast - iNumPicRcvd + m_pcCfg->getGOPEntry(iGOPid).m_POC - isField; 481 iTimeOffset = m_pcCfg->getGOPEntry(iGOPid).m_POC; 482 } 483 472 484 if(pocCurr>=m_pcCfg->getFramesToBeEncoded()) 473 485 { … … 490 502 accessUnitsInGOP.push_back(AccessUnit()); 491 503 AccessUnit& accessUnit = accessUnitsInGOP.back(); 492 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr );504 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr, isField ); 493 505 494 506 // Slice data initialization … … 499 511 #if SVC_EXTENSION 500 512 pcPic->setLayerId( m_layerId ); 501 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), m_pcEncTop->getVPS() ); 502 #else 503 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() ); 504 #endif 513 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), m_pcEncTop->getVPS(), isField ); 514 #else 515 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), isField ); 516 #endif 517 518 //Set Frame/Field coding 519 pcSlice->getPic()->setField(isField); 520 505 521 #if POC_RESET_FLAG 506 522 if( !pcSlice->getPocResetFlag() ) // For picture that are not reset, we should adjust the value of POC calculated from the configuration files. … … 602 618 pcSlice->setLFCrossSliceBoundaryFlag( pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() ); 603 619 pcSlice->setScalingList ( m_pcEncTop->getScalingList() ); 604 pcSlice->getScalingList()->setUseTransformSkip(m_pcEncTop->getPPS()->getUseTransformSkip());605 620 if(m_pcEncTop->getUseScalingListId() == SCALING_LIST_OFF) 606 621 { … … 818 833 } 819 834 } 820 #endif // SVC_EXTENSION835 #endif //#if SVC_EXTENSION 821 836 if(pcSlice->getTemporalLayerNonReferenceFlag()) 822 837 { 823 if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R) 838 if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_R && 839 !(m_iGopSize == 1 && pcSlice->getSliceType() == I_SLICE)) 840 // Add this condition to avoid POC issues with encoder_intra_main.cfg configuration (see #1127 in bug tracker) 824 841 { 825 842 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TRAIL_N); … … 863 880 else 864 881 { 865 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_T SA_R);882 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA_R); 866 883 } 867 884 #if ALIGN_TSA_STSA_PICS … … 875 892 { 876 893 assert( ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N ) || 877 ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_T SA_R ) );894 ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA_R ) ); 878 895 // TSA pictures are aligned within an access unit. 879 896 } … … 1019 1036 if( pcSlice->getMFMEnabledFlag() ) 1020 1037 #else 1021 1022 #endif 1023 1024 1038 if( pcSlice->getSPS()->getMFMEnabledFlag() ) 1039 #endif 1040 { 1041 pcSlice->setRefPOCListILP(m_pcEncTop->getIlpList(), pcSlice->getBaseColPic()); 1025 1042 #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING 1026 1027 #endif 1028 1029 #else 1030 // Set reference list1031 pcSlice->setRefPicList ( rcListPic );1043 pcSlice->setMotionPredIlp(getMotionPredIlp(pcSlice)); 1044 #endif 1045 } 1046 #else 1047 // Set reference list 1048 pcSlice->setRefPicList ( rcListPic ); 1032 1049 #endif //SVC_EXTENSION 1033 1050 pcSlice->setRefPicListModificationSvc(); … … 1080 1097 #endif 1081 1098 } 1082 #endif 1099 #else //SVC_EXTENSION 1100 // Set reference list 1101 pcSlice->setRefPicList ( rcListPic ); 1102 #endif //#if SVC_EXTENSION 1083 1103 1084 1104 // Slice info. refinement … … 1662 1682 } 1663 1683 } 1664 pictureTimingSEI.m_auCpbRemovalDelay = std::m ax<Int>(1, m_totalCoded - m_lastBPSEI); // Syntax element signalled as minus, hence the .1684 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 . 1665 1685 #if POC_RESET_FLAG 1666 1686 pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(0) + pocCurr - m_totalCoded; … … 2201 2221 xCalculateAddPSNR( pcPic, pcPic->getPicYuvRec(), accessUnit, dEncTime ); 2202 2222 2223 //In case of field coding, compute the interlaced PSNR for both fields 2224 if (isField && ((!pcPic->isTopField() && isTff) || (pcPic->isTopField() && !isTff))) 2225 { 2226 //get complementary top field 2227 TComPic* pcPicTop; 2228 TComList<TComPic*>::iterator iterPic = rcListPic.begin(); 2229 while ((*iterPic)->getPOC() != pcPic->getPOC()-1) 2230 { 2231 iterPic ++; 2232 } 2233 pcPicTop = *(iterPic); 2234 xCalculateInterlacedAddPSNR(pcPicTop, pcPic, pcPicTop->getPicYuvRec(), pcPic->getPicYuvRec(), accessUnit, dEncTime ); 2235 } 2236 2203 2237 if (digestStr) 2204 2238 { … … 2333 2367 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer()); 2334 2368 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 2369 pictureTimingSEI.m_picStruct = (isField && pcSlice->getPic()->isTopField())? 1 : isField? 2 : 0; 2335 2370 m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS()); 2336 2371 writeRBSPTrailingBits(nalu.m_Bitstream); … … 2451 2486 2452 2487 #if SVC_EXTENSION 2453 assert ( m_iNumPicCoded <= 1 );2454 #else 2455 assert ( m_iNumPicCoded == iNumPicRcvd);2488 assert ( m_iNumPicCoded <= 1 || (isField && iPOCLast == 1) ); 2489 #else 2490 assert ( (m_iNumPicCoded == iNumPicRcvd) || (isField && iPOCLast == 1) ); 2456 2491 #endif 2457 2492 } 2458 2493 2459 2494 #if !SVC_EXTENSION 2460 Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded )2495 Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded, Bool isField) 2461 2496 { 2462 2497 assert (uiNumAllPicCoded == m_gcAnalyzeAll.getNumPic()); … … 2464 2499 2465 2500 //--CFG_KDY 2466 m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() ); 2467 m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() ); 2468 m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() ); 2469 m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() ); 2501 if(isField) 2502 { 2503 m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() * 2); 2504 m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() * 2); 2505 m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() * 2); 2506 m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() * 2); 2507 } 2508 else 2509 { 2510 m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() ); 2511 m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() ); 2512 m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() ); 2513 m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() ); 2514 } 2470 2515 2471 2516 //-- all … … 2490 2535 m_gcAnalyzeB.printSummary('B'); 2491 2536 #endif 2537 2538 if(isField) 2539 { 2540 //-- interlaced summary 2541 m_gcAnalyzeAll_in.setFrmRate( m_pcCfg->getFrameRate()); 2542 printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" ); 2543 m_gcAnalyzeAll_in.printOutInterlaced('a', m_gcAnalyzeAll.getBits()); 2544 2545 #if _SUMMARY_OUT_ 2546 m_gcAnalyzeAll_in.printSummaryOutInterlaced(); 2547 #endif 2548 } 2492 2549 2493 2550 printf("\nRVM: %.3lf\n" , xCalculateRVM()); … … 2531 2588 // ==================================================================================================================== 2532 2589 2590 2591 Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Bool isField ) 2592 { 2593 assert( iNumPicRcvd > 0 ); 2594 // Exception for the first frames 2595 if ( ( isField && (iPOCLast == 0 || iPOCLast == 1) ) || (!isField && (iPOCLast == 0)) ) 2596 { 2597 m_iGopSize = 1; 2598 } 2599 else 2600 { 2601 m_iGopSize = m_pcCfg->getGOPSize(); 2602 } 2603 assert (m_iGopSize > 0); 2604 2605 return; 2606 } 2607 2533 2608 Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut ) 2534 2609 { … … 2553 2628 TComPic*& rpcPic, 2554 2629 TComPicYuv*& rpcPicYuvRecOut, 2555 Int pocCurr ) 2630 Int pocCurr, 2631 Bool isField) 2556 2632 { 2557 2633 Int i; 2558 2634 // Rec. output 2559 2635 TComList<TComPicYuv*>::iterator iterPicYuvRec = rcListPicYuvRecOut.end(); 2560 for ( i = 0; i < iNumPicRcvd - iTimeOffset + 1; i++ ) 2561 { 2562 iterPicYuvRec--; 2563 } 2564 2636 2637 if (isField) 2638 { 2639 for ( i = 0; i < ( (pocCurr == 0 ) || (pocCurr == 1 ) ? (iNumPicRcvd - iTimeOffset + 1) : (iNumPicRcvd - iTimeOffset + 2) ); i++ ) 2640 { 2641 iterPicYuvRec--; 2642 } 2643 } 2644 else 2645 { 2646 for ( i = 0; i < (iNumPicRcvd - iTimeOffset + 1); i++ ) 2647 { 2648 iterPicYuvRec--; 2649 } 2650 } 2651 2652 if (isField) 2653 { 2654 if(pocCurr == 1) 2655 { 2656 iterPicYuvRec++; 2657 } 2658 } 2565 2659 rpcPicYuvRecOut = *(iterPicYuvRec); 2566 2660 … … 2647 2741 switch (type) 2648 2742 { 2649 case NAL_UNIT_CODED_SLICE_TRAIL_R: return "TRAIL_R";2650 case NAL_UNIT_CODED_SLICE_TRAIL_N: return "TRAIL_N";2651 case NAL_UNIT_CODED_SLICE_T SA_R: return "TSA_R";2652 case NAL_UNIT_CODED_SLICE_TSA_N: return "TSA_N";2653 case NAL_UNIT_CODED_SLICE_STSA_R: return "STSA_R";2654 case NAL_UNIT_CODED_SLICE_STSA_N: return "STSA_N";2743 case NAL_UNIT_CODED_SLICE_TRAIL_R: return "TRAIL_R"; 2744 case NAL_UNIT_CODED_SLICE_TRAIL_N: return "TRAIL_N"; 2745 case NAL_UNIT_CODED_SLICE_TLA_R: return "TLA_R"; 2746 case NAL_UNIT_CODED_SLICE_TSA_N: return "TSA_N"; 2747 case NAL_UNIT_CODED_SLICE_STSA_R: return "STSA_R"; 2748 case NAL_UNIT_CODED_SLICE_STSA_N: return "STSA_N"; 2655 2749 case NAL_UNIT_CODED_SLICE_BLA_W_LP: return "BLA_W_LP"; 2656 2750 case NAL_UNIT_CODED_SLICE_BLA_W_RADL: return "BLA_W_RADL"; 2657 case NAL_UNIT_CODED_SLICE_BLA_N_LP: return "BLA_N_LP";2751 case NAL_UNIT_CODED_SLICE_BLA_N_LP: return "BLA_N_LP"; 2658 2752 case NAL_UNIT_CODED_SLICE_IDR_W_RADL: return "IDR_W_RADL"; 2659 case NAL_UNIT_CODED_SLICE_IDR_N_LP: return "IDR_N_LP";2660 case NAL_UNIT_CODED_SLICE_CRA: return "CRA";2753 case NAL_UNIT_CODED_SLICE_IDR_N_LP: return "IDR_N_LP"; 2754 case NAL_UNIT_CODED_SLICE_CRA: return "CRA"; 2661 2755 case NAL_UNIT_CODED_SLICE_RADL_R: return "RADL_R"; 2662 2756 case NAL_UNIT_CODED_SLICE_RASL_R: return "RASL_R"; 2663 case NAL_UNIT_VPS: return "VPS";2664 case NAL_UNIT_SPS: return "SPS";2665 case NAL_UNIT_PPS: return "PPS";2666 case NAL_UNIT_ACCESS_UNIT_DELIMITER: return "AUD";2667 case NAL_UNIT_EOS: return "EOS";2668 case NAL_UNIT_EOB: return "EOB";2669 case NAL_UNIT_FILLER_DATA: return "FILLER";2757 case NAL_UNIT_VPS: return "VPS"; 2758 case NAL_UNIT_SPS: return "SPS"; 2759 case NAL_UNIT_PPS: return "PPS"; 2760 case NAL_UNIT_ACCESS_UNIT_DELIMITER: return "AUD"; 2761 case NAL_UNIT_EOS: return "EOS"; 2762 case NAL_UNIT_EOB: return "EOB"; 2763 case NAL_UNIT_FILLER_DATA: return "FILLER"; 2670 2764 case NAL_UNIT_PREFIX_SEI: return "SEI"; 2671 2765 case NAL_UNIT_SUFFIX_SEI: return "SEI"; 2672 default: return "UNK";2766 default: return "UNK"; 2673 2767 } 2674 2768 } … … 2874 2968 printf("]"); 2875 2969 } 2970 } 2971 2972 2973 Void reinterlace(Pel* top, Pel* bottom, Pel* dst, UInt stride, UInt width, UInt height, Bool isTff) 2974 { 2975 2976 for (Int y = 0; y < height; y++) 2977 { 2978 for (Int x = 0; x < width; x++) 2979 { 2980 dst[x] = isTff ? (UChar) top[x] : (UChar) bottom[x]; 2981 dst[stride+x] = isTff ? (UChar) bottom[x] : (UChar) top[x]; 2982 } 2983 top += stride; 2984 bottom += stride; 2985 dst += stride*2; 2986 } 2987 } 2988 2989 Void TEncGOP::xCalculateInterlacedAddPSNR( TComPic* pcPicOrgTop, TComPic* pcPicOrgBottom, TComPicYuv* pcPicRecTop, TComPicYuv* pcPicRecBottom, const AccessUnit& accessUnit, Double dEncTime ) 2990 { 2991 Int x, y; 2992 2993 UInt64 uiSSDY_in = 0; 2994 UInt64 uiSSDU_in = 0; 2995 UInt64 uiSSDV_in = 0; 2996 2997 Double dYPSNR_in = 0.0; 2998 Double dUPSNR_in = 0.0; 2999 Double dVPSNR_in = 0.0; 3000 3001 /*------ INTERLACED PSNR -----------*/ 3002 3003 /* Luma */ 3004 3005 Pel* pOrgTop = pcPicOrgTop->getPicYuvOrg()->getLumaAddr(); 3006 Pel* pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getLumaAddr(); 3007 Pel* pRecTop = pcPicRecTop->getLumaAddr(); 3008 Pel* pRecBottom = pcPicRecBottom->getLumaAddr(); 3009 3010 Int iWidth; 3011 Int iHeight; 3012 Int iStride; 3013 3014 iWidth = pcPicOrgTop->getPicYuvOrg()->getWidth () - m_pcEncTop->getPad(0); 3015 iHeight = pcPicOrgTop->getPicYuvOrg()->getHeight() - m_pcEncTop->getPad(1); 3016 iStride = pcPicOrgTop->getPicYuvOrg()->getStride(); 3017 Int iSize = iWidth*iHeight; 3018 bool isTff = pcPicOrgTop->isTopField(); 3019 3020 TComPicYuv* pcOrgInterlaced = new TComPicYuv; 3021 pcOrgInterlaced->create( iWidth, iHeight << 1, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 3022 3023 TComPicYuv* pcRecInterlaced = new TComPicYuv; 3024 pcRecInterlaced->create( iWidth, iHeight << 1, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 3025 3026 Pel* pOrgInterlaced = pcOrgInterlaced->getLumaAddr(); 3027 Pel* pRecInterlaced = pcRecInterlaced->getLumaAddr(); 3028 3029 //=== Interlace fields ==== 3030 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 3031 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 3032 3033 //===== calculate PSNR ===== 3034 for( y = 0; y < iHeight << 1; y++ ) 3035 { 3036 for( x = 0; x < iWidth; x++ ) 3037 { 3038 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 3039 uiSSDY_in += iDiff * iDiff; 3040 } 3041 pOrgInterlaced += iStride; 3042 pRecInterlaced += iStride; 3043 } 3044 3045 /*Chroma*/ 3046 3047 iHeight >>= 1; 3048 iWidth >>= 1; 3049 iStride >>= 1; 3050 3051 pOrgTop = pcPicOrgTop->getPicYuvOrg()->getCbAddr(); 3052 pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getCbAddr(); 3053 pRecTop = pcPicRecTop->getCbAddr(); 3054 pRecBottom = pcPicRecBottom->getCbAddr(); 3055 pOrgInterlaced = pcOrgInterlaced->getCbAddr(); 3056 pRecInterlaced = pcRecInterlaced->getCbAddr(); 3057 3058 //=== Interlace fields ==== 3059 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 3060 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 3061 3062 //===== calculate PSNR ===== 3063 for( y = 0; y < iHeight << 1; y++ ) 3064 { 3065 for( x = 0; x < iWidth; x++ ) 3066 { 3067 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 3068 uiSSDU_in += iDiff * iDiff; 3069 } 3070 pOrgInterlaced += iStride; 3071 pRecInterlaced += iStride; 3072 } 3073 3074 pOrgTop = pcPicOrgTop->getPicYuvOrg()->getCrAddr(); 3075 pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getCrAddr(); 3076 pRecTop = pcPicRecTop->getCrAddr(); 3077 pRecBottom = pcPicRecBottom->getCrAddr(); 3078 pOrgInterlaced = pcOrgInterlaced->getCrAddr(); 3079 pRecInterlaced = pcRecInterlaced->getCrAddr(); 3080 3081 //=== Interlace fields ==== 3082 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 3083 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 3084 3085 //===== calculate PSNR ===== 3086 for( y = 0; y < iHeight << 1; y++ ) 3087 { 3088 for( x = 0; x < iWidth; x++ ) 3089 { 3090 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 3091 uiSSDV_in += iDiff * iDiff; 3092 } 3093 pOrgInterlaced += iStride; 3094 pRecInterlaced += iStride; 3095 } 3096 3097 Int maxvalY = 255 << (g_bitDepthY-8); 3098 Int maxvalC = 255 << (g_bitDepthC-8); 3099 Double fRefValueY = (Double) maxvalY * maxvalY * iSize*2; 3100 Double fRefValueC = (Double) maxvalC * maxvalC * iSize*2 / 4.0; 3101 dYPSNR_in = ( uiSSDY_in ? 10.0 * log10( fRefValueY / (Double)uiSSDY_in ) : 99.99 ); 3102 dUPSNR_in = ( uiSSDU_in ? 10.0 * log10( fRefValueC / (Double)uiSSDU_in ) : 99.99 ); 3103 dVPSNR_in = ( uiSSDV_in ? 10.0 * log10( fRefValueC / (Double)uiSSDV_in ) : 99.99 ); 3104 3105 /* calculate the size of the access unit, excluding: 3106 * - any AnnexB contributions (start_code_prefix, zero_byte, etc.,) 3107 * - SEI NAL units 3108 */ 3109 UInt numRBSPBytes = 0; 3110 for (AccessUnit::const_iterator it = accessUnit.begin(); it != accessUnit.end(); it++) 3111 { 3112 UInt numRBSPBytes_nal = UInt((*it)->m_nalUnitData.str().size()); 3113 3114 if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI) 3115 numRBSPBytes += numRBSPBytes_nal; 3116 } 3117 3118 UInt uibits = numRBSPBytes * 8 ; 3119 3120 //===== add PSNR ===== 3121 m_gcAnalyzeAll_in.addResult (dYPSNR_in, dUPSNR_in, dVPSNR_in, (Double)uibits); 3122 3123 printf("\n Interlaced frame %d: [Y %6.4lf dB U %6.4lf dB V %6.4lf dB]", pcPicOrgBottom->getPOC()/2 , dYPSNR_in, dUPSNR_in, dVPSNR_in ); 3124 3125 pcOrgInterlaced->destroy(); 3126 delete pcOrgInterlaced; 3127 pcRecInterlaced->destroy(); 3128 delete pcRecInterlaced; 2876 3129 } 2877 3130 -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncGOP.h
r345 r431 145 145 Void init ( TEncTop* pcTEncTop ); 146 146 #if SVC_EXTENSION 147 Void compressGOP ( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );147 Void compressGOP ( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff ); 148 148 #else 149 Void compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );149 Void compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff ); 150 150 #endif 151 151 Void xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect); … … 156 156 TComList<TComPic*>* getListPic() { return m_pcListPic; } 157 157 158 Void printOutSummary ( UInt uiNumAllPicCoded ); 158 #if !SVC_EXTENSION 159 Void printOutSummary ( UInt uiNumAllPicCoded, Bool isField); 160 #endif 159 161 Void preLoopFilterPicAll ( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits ); 160 162 … … 166 168 167 169 protected: 170 171 Void xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Bool isField ); 168 172 Void xInitGOP ( Int iPOC, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut ); 169 Void xGetBuffer ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr );173 Void xGetBuffer ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, Bool isField ); 170 174 171 175 Void xCalculateAddPSNR ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime ); 176 Void xCalculateInterlacedAddPSNR( TComPic* pcPicOrgTop, TComPic* pcPicOrgBottom, TComPicYuv* pcPicRecTop, TComPicYuv* pcPicRecBottom, const AccessUnit& accessUnit, Double dEncTime ); 172 177 173 178 UInt64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1); -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncSlice.cpp
r401 r431 180 180 #if SVC_EXTENSION 181 181 //\param vps VPS associated with the slice 182 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps )183 #else 184 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS )182 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps, Bool isField ) 183 #else 184 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, Bool isField ) 185 185 #endif 186 186 { … … 298 298 Int NumberBFrames = ( m_pcCfg->getGOPSize() - 1 ); 299 299 Int SHIFT_QP = 12; 300 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)NumberBFrames ); 300 301 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)(isField ? NumberBFrames/2 : NumberBFrames) ); 302 301 303 #if FULL_NBIT 302 304 Int bitdepth_luma_qp_scale = 6 * (g_bitDepth - 8); -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncSlice.h
r313 r431 118 118 #if SVC_EXTENSION 119 119 Void initEncSlice ( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, 120 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps );120 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps, Bool isField ); 121 121 #else 122 122 Void initEncSlice ( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, 123 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS );123 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, Bool isField ); 124 124 #endif 125 125 -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncTop.cpp
r414 r431 308 308 } 309 309 310 Void TEncTop::init( )310 Void TEncTop::init(Bool isFieldCoding) 311 311 { 312 312 // initialize SPS … … 319 319 m_cPPS.setSPS(&m_cSPS); 320 320 xInitPPS(); 321 xInitRPS( );321 xInitRPS(isFieldCoding); 322 322 323 323 xInitPPSforTiles(); … … 396 396 397 397 // compress GOP 398 m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut );398 m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false); 399 399 400 400 #if RATE_CONTROL_LAMBDA_DOMAIN … … 456 456 457 457 // compress GOP 458 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut); 458 459 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false); 459 460 460 461 #if RATE_CONTROL_LAMBDA_DOMAIN … … 467 468 iNumEncoded = m_iNumPicRcvd; 468 469 m_iNumPicRcvd = 0; 470 m_uiNumAllPicCoded += iNumEncoded; 471 } 472 #endif 473 474 /**------------------------------------------------ 475 Separate interlaced frame into two fields 476 -------------------------------------------------**/ 477 void separateFields(Pel* org, Pel* dstField, UInt stride, UInt width, UInt height, Bool isTop) 478 { 479 if (!isTop) 480 { 481 org += stride; 482 } 483 for (Int y = 0; y < height>>1; y++) 484 { 485 for (Int x = 0; x < width; x++) 486 { 487 dstField[x] = org[x]; 488 } 489 490 dstField += stride; 491 org += stride*2; 492 } 493 494 } 495 496 #if SVC_EXTENSION 497 Void TEncTop::encodePrep( TComPicYuv* pcPicYuvOrg, Bool isTff ) 498 { 499 if (pcPicYuvOrg) 500 { 501 /* -- TOP FIELD -- */ 502 /* -- Top field initialization -- */ 503 504 TComPic *pcTopField; 505 xGetNewPicBuffer( pcTopField ); 506 pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO); 507 pcTopField->setReconMark (false); 508 509 pcTopField->getSlice(0)->setPOC( m_iPOCLast ); 510 pcTopField->getPicYuvRec()->setBorderExtension(false); 511 pcTopField->setTopField(isTff); 512 513 Int nHeight = pcPicYuvOrg->getHeight(); 514 Int nWidth = pcPicYuvOrg->getWidth(); 515 Int nStride = pcPicYuvOrg->getStride(); 516 Int nPadLuma = pcPicYuvOrg->getLumaMargin(); 517 Int nPadChroma = pcPicYuvOrg->getChromaMargin(); 518 519 // Get pointers 520 Pel * PicBufY = pcPicYuvOrg->getBufY(); 521 Pel * PicBufU = pcPicYuvOrg->getBufU(); 522 Pel * PicBufV = pcPicYuvOrg->getBufV(); 523 524 Pel * pcTopFieldY = pcTopField->getPicYuvOrg()->getLumaAddr(); 525 Pel * pcTopFieldU = pcTopField->getPicYuvOrg()->getCbAddr(); 526 Pel * pcTopFieldV = pcTopField->getPicYuvOrg()->getCrAddr(); 527 528 // compute image characteristics 529 if ( getUseAdaptiveQP() ) 530 { 531 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcTopField ) ); 532 } 533 534 /* -- Defield -- */ 535 536 Bool isTop = isTff; 537 538 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcTopFieldY, nStride, nWidth, nHeight, isTop); 539 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 540 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 541 542 /* -- BOTTOM FIELD -- */ 543 /* -- Bottom field initialization -- */ 544 545 TComPic* pcBottomField; 546 xGetNewPicBuffer( pcBottomField ); 547 pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO); 548 pcBottomField->setReconMark (false); 549 550 pcBottomField->getSlice(0)->setPOC( m_iPOCLast); 551 pcBottomField->getPicYuvRec()->setBorderExtension(false); 552 pcBottomField->setTopField(!isTff); 553 554 nHeight = pcPicYuvOrg->getHeight(); 555 nWidth = pcPicYuvOrg->getWidth(); 556 nStride = pcPicYuvOrg->getStride(); 557 nPadLuma = pcPicYuvOrg->getLumaMargin(); 558 nPadChroma = pcPicYuvOrg->getChromaMargin(); 559 560 // Get pointers 561 PicBufY = pcPicYuvOrg->getBufY(); 562 PicBufU = pcPicYuvOrg->getBufU(); 563 PicBufV = pcPicYuvOrg->getBufV(); 564 565 Pel * pcBottomFieldY = pcBottomField->getPicYuvOrg()->getLumaAddr(); 566 Pel * pcBottomFieldU = pcBottomField->getPicYuvOrg()->getCbAddr(); 567 Pel * pcBottomFieldV = pcBottomField->getPicYuvOrg()->getCrAddr(); 568 569 // Compute image characteristics 570 if ( getUseAdaptiveQP() ) 571 { 572 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcBottomField ) ); 573 } 574 575 /* -- Defield -- */ 576 577 isTop = !isTff; 578 579 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcBottomFieldY, nStride, nWidth, nHeight, isTop); 580 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 581 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 582 583 } 584 } 585 586 Void TEncTop::encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP, Bool isTff ) 587 { 588 // compress GOP 589 if (m_iPOCLast == 0) // compress field 0 590 { 591 m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 592 } 593 594 if (pcPicYuvOrg) 595 { 596 TComPicYuv* rpcPicYuvRec = new TComPicYuv; 597 if ( rcListPicYuvRecOut.size() == (UInt)m_iGOPSize ) 598 { 599 rpcPicYuvRec = rcListPicYuvRecOut.popFront(); 600 } 601 else 602 { 603 rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 604 } 605 rcListPicYuvRecOut.pushBack( rpcPicYuvRec ); 606 } 607 608 // compress GOP 609 m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 610 611 m_uiNumAllPicCoded ++; 612 } 613 #else 614 Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff) 615 { 616 /* -- TOP FIELD -- */ 617 618 if (pcPicYuvOrg) 619 { 620 621 /* -- Top field initialization -- */ 622 623 TComPic *pcTopField; 624 xGetNewPicBuffer( pcTopField ); 625 pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO); 626 pcTopField->setReconMark (false); 627 628 pcTopField->getSlice(0)->setPOC( m_iPOCLast ); 629 pcTopField->getPicYuvRec()->setBorderExtension(false); 630 pcTopField->setTopField(isTff); 631 632 Int nHeight = pcPicYuvOrg->getHeight(); 633 Int nWidth = pcPicYuvOrg->getWidth(); 634 Int nStride = pcPicYuvOrg->getStride(); 635 Int nPadLuma = pcPicYuvOrg->getLumaMargin(); 636 Int nPadChroma = pcPicYuvOrg->getChromaMargin(); 637 638 // Get pointers 639 Pel * PicBufY = pcPicYuvOrg->getBufY(); 640 Pel * PicBufU = pcPicYuvOrg->getBufU(); 641 Pel * PicBufV = pcPicYuvOrg->getBufV(); 642 643 Pel * pcTopFieldY = pcTopField->getPicYuvOrg()->getLumaAddr(); 644 Pel * pcTopFieldU = pcTopField->getPicYuvOrg()->getCbAddr(); 645 Pel * pcTopFieldV = pcTopField->getPicYuvOrg()->getCrAddr(); 646 647 // compute image characteristics 648 if ( getUseAdaptiveQP() ) 649 { 650 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcTopField ) ); 651 } 652 653 /* -- Defield -- */ 654 655 Bool isTop = isTff; 656 657 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcTopFieldY, nStride, nWidth, nHeight, isTop); 658 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 659 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 660 661 } 662 663 if (m_iPOCLast == 0) // compress field 0 664 { 665 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 666 } 667 668 /* -- BOTTOM FIELD -- */ 669 670 if (pcPicYuvOrg) 671 { 672 673 /* -- Bottom field initialization -- */ 674 675 TComPic* pcBottomField; 676 xGetNewPicBuffer( pcBottomField ); 677 pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO); 678 pcBottomField->setReconMark (false); 679 680 TComPicYuv* rpcPicYuvRec = new TComPicYuv; 681 if ( rcListPicYuvRecOut.size() == (UInt)m_iGOPSize ) 682 { 683 rpcPicYuvRec = rcListPicYuvRecOut.popFront(); 684 } 685 else 686 { 687 rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 688 } 689 rcListPicYuvRecOut.pushBack( rpcPicYuvRec ); 690 691 pcBottomField->getSlice(0)->setPOC( m_iPOCLast); 692 pcBottomField->getPicYuvRec()->setBorderExtension(false); 693 pcBottomField->setTopField(!isTff); 694 695 int nHeight = pcPicYuvOrg->getHeight(); 696 int nWidth = pcPicYuvOrg->getWidth(); 697 int nStride = pcPicYuvOrg->getStride(); 698 int nPadLuma = pcPicYuvOrg->getLumaMargin(); 699 int nPadChroma = pcPicYuvOrg->getChromaMargin(); 700 701 // Get pointers 702 Pel * PicBufY = pcPicYuvOrg->getBufY(); 703 Pel * PicBufU = pcPicYuvOrg->getBufU(); 704 Pel * PicBufV = pcPicYuvOrg->getBufV(); 705 706 Pel * pcBottomFieldY = pcBottomField->getPicYuvOrg()->getLumaAddr(); 707 Pel * pcBottomFieldU = pcBottomField->getPicYuvOrg()->getCbAddr(); 708 Pel * pcBottomFieldV = pcBottomField->getPicYuvOrg()->getCrAddr(); 709 710 // Compute image characteristics 711 if ( getUseAdaptiveQP() ) 712 { 713 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcBottomField ) ); 714 } 715 716 /* -- Defield -- */ 717 718 Bool isTop = !isTff; 719 720 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcBottomFieldY, nStride, nWidth, nHeight, isTop); 721 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 722 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 723 724 } 725 726 if ( ( !(m_iNumPicRcvd) || (!flush && m_iPOCLast != 1 && m_iNumPicRcvd != m_iGOPSize && m_iGOPSize)) ) 727 { 728 iNumEncoded = 0; 729 return; 730 } 731 732 // compress GOP 733 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 734 735 iNumEncoded = m_iNumPicRcvd; 736 m_iNumPicRcvd = 0; 469 737 m_uiNumAllPicCoded += iNumEncoded; 470 738 } … … 911 1179 912 1180 //Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file. 913 Void TEncTop::xInitRPS( )1181 Void TEncTop::xInitRPS(Bool isFieldCoding) 914 1182 { 915 1183 TComReferencePictureSet* rps; 916 1184 917 m_cSPS.createRPSList(getGOPSize()+m_extraRPSs );1185 m_cSPS.createRPSList(getGOPSize()+m_extraRPSs+1); 918 1186 TComRPSList* rpsList = m_cSPS.getRPSList(); 919 1187 … … 1016 1284 printf("Warning: number of negative pictures in RPS is different between intra and inter RPS specified in the config file.\n"); 1017 1285 rps->setNumberOfNegativePictures(numNeg); 1018 rps->setNumberOfP ositivePictures(numNeg+numPos);1286 rps->setNumberOfPictures(numNeg+numPos); 1019 1287 } 1020 1288 if (numPos != rps->getNumberOfPositivePictures()) … … 1022 1290 printf("Warning: number of positive pictures in RPS is different between intra and inter RPS specified in the config file.\n"); 1023 1291 rps->setNumberOfPositivePictures(numPos); 1024 rps->setNumberOfP ositivePictures(numNeg+numPos);1292 rps->setNumberOfPictures(numNeg+numPos); 1025 1293 } 1026 1294 RPSTemp.setNumberOfPictures(numNeg+numPos); … … 1086 1354 #endif //INTER_RPS_AUTO 1087 1355 } 1088 1356 //In case of field coding, we need to set special parameters for the first bottom field of the sequence, since it is not specified in the cfg file. 1357 //The position = GOPSize + extraRPSs which is (a priori) unused is reserved for this field in the RPS. 1358 if (isFieldCoding) 1359 { 1360 rps = rpsList->getReferencePictureSet(getGOPSize()+m_extraRPSs); 1361 rps->setNumberOfPictures(1); 1362 rps->setNumberOfNegativePictures(1); 1363 rps->setNumberOfPositivePictures(0); 1364 rps->setNumberOfLongtermPictures(0); 1365 rps->setDeltaPOC(0,-1); 1366 rps->setPOC(0,0); 1367 rps->setUsed(0,true); 1368 rps->setInterRPSPrediction(false); 1369 rps->setDeltaRIdxMinus1(0); 1370 rps->setDeltaRPS(0); 1371 rps->setNumRefIdc(0); 1372 } 1089 1373 } 1090 1374 … … 1095 1379 { 1096 1380 slice->setRPSidx(GOPid); 1097 1098 1381 for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) 1099 1382 { … … 1119 1402 } 1120 1403 1404 if(POCCurr == 1 && slice->getPic()->isField()) 1405 { 1406 slice->setRPSidx(m_iGOPSize+m_extraRPSs); 1407 } 1408 1121 1409 slice->setRPS(getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx())); 1122 1410 slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures()); 1123 1124 1411 } 1125 1412 -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncTop.h
r414 r431 144 144 Window m_scaledRefLayerWindow[MAX_LAYERS]; 145 145 #endif 146 #endif147 146 #if POC_RESET_FLAG 148 147 Int m_pocAdjustmentValue; 148 #endif 149 149 #endif 150 150 protected: … … 154 154 155 155 Void xInitPPSforTiles (); 156 Void xInitRPS ( );///< initialize PPS from encoder options156 Void xInitRPS (Bool isFieldCoding); ///< initialize PPS from encoder options 157 157 #if SVC_EXTENSION 158 158 Void xInitILRP(); … … 164 164 Void create (); 165 165 Void destroy (); 166 Void init ( );166 Void init (Bool isFieldCoding); 167 167 Void deletePicBuffer (); 168 168 … … 209 209 Int getNumPicRcvd () { return m_iNumPicRcvd; } 210 210 Void setNumPicRcvd ( Int num ) { m_iNumPicRcvd = num; } 211 #endif212 211 #if SCALED_REF_LAYER_OFFSETS 213 212 Void setNumScaledRefLayerOffsets(Int x) { m_numScaledRefLayerOffsets = x; } 214 213 UInt getNumScaledRefLayerOffsets() { return m_numScaledRefLayerOffsets; } 215 214 Window& getScaledRefLayerWindow(Int x) { return m_scaledRefLayerWindow[x]; } 215 #endif 216 216 #endif 217 217 … … 236 236 fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; } 237 237 #endif 238 Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP 238 Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP ); 239 239 Void encodePrep( TComPicYuv* pcPicYuvOrg ); 240 Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP, Bool isTff ); 241 Void encodePrep( TComPicYuv* pcPicYuvOrg, Bool isTff ); 240 242 #if VPS_EXTN_DIRECT_REF_LAYERS 241 243 TEncTop* getRefLayerEnc(UInt refLayerIdc); 242 244 #endif 243 #else244 Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,245 std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded );246 #endif247 248 void printSummary() { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded); }249 245 #if POC_RESET_FLAG 250 246 Int getPocAdjustmentValue() { return m_pocAdjustmentValue;} 251 247 Void setPocAdjustmentValue(Int x) { m_pocAdjustmentValue = x; } 252 248 #endif 249 #else //SVC_EXTENSION 250 Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, 251 std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ); 252 253 /// encode several number of pictures until end-of-sequence 254 Void encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, 255 std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff); 256 257 Void printSummary(Bool isField) { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded, isField); } 258 #endif //#if SVC_EXTENSION 253 259 }; 254 260
Note: See TracChangeset for help on using the changeset viewer.