Changeset 655 in 3DVCSoftware for trunk/source/Lib/TLibEncoder/TEncGOP.cpp
- Timestamp:
- 23 Oct 2013, 23:01:30 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibEncoder/TEncGOP.cpp
r622 r655 153 153 #endif 154 154 #endif 155 156 #if KWU_FIX_URQ 157 m_pcRateCtrl = pcTEncTop->getRateCtrl(); 158 #endif 155 159 } 156 160 … … 351 355 #endif 352 356 #if H_MV 353 Void TEncGOP::compressPicInGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Int iGOPid )354 #else 355 Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP )357 Void TEncGOP::compressPicInGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Int iGOPid, bool isField, bool isTff) 358 #else 359 Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, bool isField, bool isTff) 356 360 #endif 357 361 { … … 367 371 368 372 #if !H_MV 369 xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut ); 373 xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut, isField ); 374 370 375 371 376 m_iNumPicCoded = 0; … … 439 444 440 445 /////////////////////////////////////////////////////////////////////////////////////////////////// Initial to start encoding 441 Int pocCurr = iPOCLast -iNumPicRcvd+ m_pcCfg->getGOPEntry(iGOPid).m_POC; 442 Int iTimeOffset = m_pcCfg->getGOPEntry(iGOPid).m_POC; 443 if(iPOCLast == 0) 446 Int iTimeOffset; 447 Int pocCurr; 448 449 if(iPOCLast == 0) //case first frame or first top field 444 450 { 445 451 pocCurr=0; 446 452 iTimeOffset = 1; 453 } 454 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 455 { 456 pocCurr = 1; 457 iTimeOffset = 1; 458 } 459 else 460 { 461 pocCurr = iPOCLast - iNumPicRcvd + m_pcCfg->getGOPEntry(iGOPid).m_POC - isField; 462 iTimeOffset = m_pcCfg->getGOPEntry(iGOPid).m_POC; 447 463 } 448 464 if(pocCurr>=m_pcCfg->getFramesToBeEncoded()) … … 463 479 accessUnitsInGOP.push_back(AccessUnit()); 464 480 AccessUnit& accessUnit = accessUnitsInGOP.back(); 465 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr 481 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr, isField); 466 482 467 483 // Slice data initialization … … 472 488 473 489 474 #if H_MV5475 490 #if H_MV 476 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getVPS(), m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), getLayerId() ); 477 #else 478 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() ); 479 #endif 480 #else 481 #if H_3D 482 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getVPS(), m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), getLayerId() ); 483 #else 484 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() ); 485 #endif 486 #endif 491 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getVPS(), m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), getLayerId(), isField ); 492 #else 493 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), isField ); 494 #endif 495 496 //Set Frame/Field coding 497 pcSlice->getPic()->setField(isField); 498 487 499 pcSlice->setLastIDR(m_iLastIDR); 488 500 pcSlice->setSliceIdx(0); 489 501 #if H_MV 490 #if H_MV5491 502 pcSlice->setRefPicSetInterLayer ( &m_refPicSetInterLayer0, &m_refPicSetInterLayer1 ); 492 #else493 pcSlice->setRefPicSetInterLayer ( &m_refPicSetInterLayer );494 #endif495 503 pcPic ->setLayerId ( getLayerId() ); 496 504 pcPic ->setViewId ( getViewId() ); … … 508 516 pcSlice->setLFCrossSliceBoundaryFlag( pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() ); 509 517 pcSlice->setScalingList ( m_pcEncTop->getScalingList() ); 510 pcSlice->getScalingList()->setUseTransformSkip(m_pcEncTop->getPPS()->getUseTransformSkip());511 518 if(m_pcEncTop->getUseScalingListId() == SCALING_LIST_OFF) 512 519 { … … 562 569 if(pcSlice->getTemporalLayerNonReferenceFlag()) 563 570 { 564 if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R) 571 if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_R && 572 !(m_iGopSize == 1 && pcSlice->getSliceType() == I_SLICE)) 573 // Add this condition to avoid POC issues with encoder_intra_main.cfg configuration (see #1127 in bug tracker) 565 574 { 566 575 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TRAIL_N); … … 655 664 refPicListModification->setRefPicListModificationFlagL1(0); 656 665 #if H_MV 657 #if H_MV5658 666 if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > 1 ) 659 667 { … … 699 707 xSetRefPicListModificationsMv( tempRefPicLists, pcSlice, iGOPid ); 700 708 #else 701 if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > 0 )702 {703 pcSlice->setDiscardableFlag ( false );704 }705 706 TComVPS* vps = pcSlice->getVPS();707 Int layerIdInVps = vps ->getLayerIdInVps( getLayerId());708 Int numDirectRefLayers = vps ->getNumDirectRefLayers( layerIdInVps );709 GOPEntry gopEntry = m_pcCfg->getGOPEntry( (pcSlice->getRapPicFlag() && getLayerId() > 0) ? MAX_GOP : iGOPid );710 711 if ( getLayerId() > 0 && numDirectRefLayers > 0 )712 {713 pcSlice->setInterLayerPredEnabledFlag ( gopEntry.m_numActiveRefLayerPics > 0 );714 if ( pcSlice->getInterLayerPredEnabledFlag() && numDirectRefLayers > 1 )715 {716 if ( !vps->getMaxOneActiveRefLayerFlag() )717 {718 pcSlice->setNumInterLayerRefPicsMinus1( gopEntry.m_numActiveRefLayerPics - 1 );719 }720 for (Int i = 0; i < gopEntry.m_numActiveRefLayerPics; i++ )721 {722 pcSlice->setInterLayerPredLayerIdc( i, gopEntry.m_interLayerPredLayerIdc[ i ] );723 }724 }725 }726 assert( pcSlice->getNumActiveRefLayerPics() == gopEntry.m_numActiveRefLayerPics );727 728 if ( vps->getNumSamplePredRefLayers( layerIdInVps ) > 0 && pcSlice->getNumActiveRefLayerPics() > 0)729 {730 pcSlice->setInterLayerSamplePredOnlyFlag( gopEntry.m_numRefPics == 0 );731 }732 733 pcSlice->createAndApplyIvReferencePictureSet( m_ivPicLists, m_refPicSetInterLayer );734 pcSlice->setNumRefIdx(REF_PIC_LIST_0,min(gopEntry.m_numRefPicsActive,( pcSlice->getRPS()->getNumberOfPictures() + (Int) m_refPicSetInterLayer.size() ) ) );735 pcSlice->setNumRefIdx(REF_PIC_LIST_1,min(gopEntry.m_numRefPicsActive,( pcSlice->getRPS()->getNumberOfPictures() + (Int) m_refPicSetInterLayer.size() ) ) );736 737 xSetRefPicListModificationsMv( pcSlice, iGOPid );738 739 pcSlice->setActiveMotionPredRefLayers( );740 741 if ( getLayerId() > 0 && pcSlice->getNumActiveMotionPredRefLayers() > 0 && pcSlice->getEnableTMVPFlag() &&742 ( pcSlice->getSliceType() == B_SLICE || pcSlice->getSliceType() == P_SLICE ))743 {744 pcSlice->setAltCollocatedIndicationFlag( gopEntry.m_collocatedRefLayerIdx >= 0 );745 if ( pcSlice->getNumActiveRefLayerPics() && pcSlice->getNumActiveMotionPredRefLayers() > 0 )746 {747 pcSlice->setCollocatedRefLayerIdx( gopEntry.m_collocatedRefLayerIdx );748 }749 }750 751 #endif752 #else753 709 pcSlice->setNumRefIdx(REF_PIC_LIST_0,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures())); 754 710 pcSlice->setNumRefIdx(REF_PIC_LIST_1,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures())); … … 760 716 761 717 // Set reference list 762 #if H_MV5763 718 #if H_MV 764 719 pcSlice->setRefPicList( tempRefPicLists, usedAsLongTerm, numPocTotalCurr ); … … 782 737 } 783 738 } 784 #endif785 #else786 #if H_MV787 pcSlice->setRefPicList( rcListPic, m_refPicSetInterLayer );788 #if H_3D_ARP789 pcSlice->setARPStepNum();790 if(pcSlice->getARPStepNum() > 1)791 {792 for(Int iLayerId = 0; iLayerId < getLayerId(); iLayerId ++ )793 {794 Int iViewIdx = pcSlice->getVPS()->getViewIndex(iLayerId);795 Bool bIsDepth = ( pcSlice->getVPS()->getDepthId ( iLayerId ) == 1 );796 if( iViewIdx<getViewIndex() && !bIsDepth )797 {798 pcSlice->setBaseViewRefPicList( m_ivPicLists->getPicList( iLayerId ), iViewIdx );799 }800 }801 }802 #endif803 #else804 pcSlice->setRefPicList ( rcListPic );805 #endif806 739 #endif 807 740 #if H_3D … … 913 846 914 847 // SAIT_VSO_EST_A0033 848 #if H_3D_FCO 849 Bool flagRec; 850 flagRec = ((m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), false, pcSlice->getPOC(), true) == NULL) ? false: true); 851 pcRdCost->setVideoRecPicYuv( m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), false, pcSlice->getPOC(), flagRec ) ); 852 pcRdCost->setDepthPicYuv ( m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), true, pcSlice->getPOC(), false ) ); 853 #else 915 854 pcRdCost->setVideoRecPicYuv( m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), false , pcSlice->getPOC(), true ) ); 916 855 pcRdCost->setDepthPicYuv ( m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), true , pcSlice->getPOC(), false ) ); 856 #endif 917 857 918 858 // LGE_WVSO_A0119 … … 970 910 } 971 911 m_pcRateCtrl->initRCPic( frameLevel ); 912 913 #if KWU_RC_MADPRED_E0227 914 if(m_pcCfg->getLayerId() != 0) 915 { 916 m_pcRateCtrl->getRCPic()->setIVPic( m_pcEncTop->getEncTop()->getTEncTop(0)->getRateCtrl()->getRCPic() ); 917 } 918 #endif 919 972 920 estimatedBits = m_pcRateCtrl->getRCPic()->getTargetBits(); 973 921 … … 1014 962 else // normal case 1015 963 { 964 #if KWU_RC_MADPRED_E0227 965 if(m_pcRateCtrl->getLayerID() != 0) 966 { 967 list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList(); 968 lambda = m_pcRateCtrl->getRCPic()->estimatePicLambdaIV( listPreviousPicture, pcSlice->getPOC() ); 969 sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture ); 970 } 971 else 972 { 973 #endif 1016 974 list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList(); 1017 975 #if RATE_CONTROL_INTRA … … 1021 979 #endif 1022 980 sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture ); 981 #if KWU_RC_MADPRED_E0227 982 } 983 #endif 1023 984 } 1024 985 … … 1155 1116 pcPic->setNumDdvCandPics(pcPic->getDisCandRefPictures(iColPoc)); 1156 1117 } 1118 #endif 1157 1119 #if H_3D 1158 1120 pcSlice->setDepthToDisparityLUTs(); 1159 1121 1160 1122 #endif 1161 #endif 1162 #if MTK_NBDV_TN_FIX_E01721123 1124 #if H_3D_NBDV 1163 1125 if(pcSlice->getViewIndex() && !pcSlice->getIsDepth() && !pcSlice->isIntra()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done. 1164 1126 { 1165 1127 pcPic->checkTemporalIVRef(); 1166 1128 } 1167 #endif 1168 #if MTK_TEXTURE_MRGCAND_BUGFIX_E0182 1129 1169 1130 if(pcSlice->getIsDepth()) 1170 1131 { … … 1412 1373 } 1413 1374 } 1414 pictureTimingSEI.m_auCpbRemovalDelay = std::m ax<Int>(1, m_totalCoded - m_lastBPSEI); // Syntax element signalled as minus, hence the .1375 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 . 1415 1376 pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(0) + pcSlice->getPOC() - m_totalCoded; 1416 1377 Int factor = pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2; … … 1862 1823 pcPic->destroyNonDBFilterInfo(); 1863 1824 } 1864 #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E01701825 #if H_3D 1865 1826 pcPic->compressMotion(2); 1866 1827 #endif … … 1898 1859 digestStr = digestToString(sei_recon_picture_digest.digest, 4); 1899 1860 } 1900 #if H_MV _FIX_LID_PIC_HASH_SEI_T401861 #if H_MV 1901 1862 OutputNALUnit nalu(NAL_UNIT_SUFFIX_SEI, pcSlice->getTLayer(), getLayerId() ); 1902 1863 #else … … 1940 1901 xCalculateAddPSNR( pcPic, pcPic->getPicYuvRec(), accessUnit, dEncTime ); 1941 1902 1903 //In case of field coding, compute the interlaced PSNR for both fields 1904 if (isField && ((!pcPic->isTopField() && isTff) || (pcPic->isTopField() && !isTff))) 1905 { 1906 //get complementary top field 1907 TComPic* pcPicTop; 1908 TComList<TComPic*>::iterator iterPic = rcListPic.begin(); 1909 while ((*iterPic)->getPOC() != pcPic->getPOC()-1) 1910 { 1911 iterPic ++; 1912 } 1913 pcPicTop = *(iterPic); 1914 xCalculateInterlacedAddPSNR(pcPicTop, pcPic, pcPicTop->getPicYuvRec(), pcPic->getPicYuvRec(), accessUnit, dEncTime ); 1915 } 1916 1942 1917 if (digestStr) 1943 1918 { … … 2072 2047 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer()); 2073 2048 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 2049 pictureTimingSEI.m_picStruct = (isField && pcSlice->getPic()->isTopField())? 1 : isField? 2 : 0; 2074 2050 m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS()); 2075 2051 writeRBSPTrailingBits(nalu.m_Bitstream); … … 2166 2142 pcPic->setReconMark ( true ); 2167 2143 #if H_MV 2168 #if H_MV52169 2144 TComSlice::markIvRefPicsAsShortTerm( m_refPicSetInterLayer0, m_refPicSetInterLayer1 ); 2170 #else2171 TComSlice::markIvRefPicsAsShortTerm( m_refPicSetInterLayer );2172 #endif2173 2145 std::vector<Int> temp; 2174 2146 TComSlice::markCurrPic( pcPic ); … … 2184 2156 delete[] pcSubstreamsOut; 2185 2157 } 2186 #if ! RATE_CONTROL_LAMBDA_DOMAIN2158 #if !KWU_FIX_URQ && !RATE_CONTROL_LAMBDA_DOMAIN 2187 2159 if(m_pcCfg->getUseRateCtrl()) 2188 2160 { … … 2196 2168 2197 2169 #if !H_MV 2198 assert ( m_iNumPicCoded == iNumPicRcvd);2170 assert ( (m_iNumPicCoded == iNumPicRcvd) || (isField && iPOCLast == 1) ); 2199 2171 #endif 2200 2172 } 2201 2173 2202 2174 #if !H_MV 2203 Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded )2175 Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded, bool isField) 2204 2176 { 2205 2177 assert (uiNumAllPicCoded == m_gcAnalyzeAll.getNumPic()); … … 2207 2179 2208 2180 //--CFG_KDY 2181 if(isField) 2182 { 2183 m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() * 2); 2184 m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() * 2); 2185 m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() * 2); 2186 m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() * 2); 2187 } 2188 else 2189 { 2209 2190 m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() ); 2210 2191 m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() ); 2211 2192 m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() ); 2212 2193 m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() ); 2194 } 2213 2195 2214 2196 //-- all … … 2233 2215 m_gcAnalyzeB.printSummary('B'); 2234 2216 #endif 2217 2218 if(isField) 2219 { 2220 //-- interlaced summary 2221 m_gcAnalyzeAll_in.setFrmRate( m_pcCfg->getFrameRate()); 2222 printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" ); 2223 m_gcAnalyzeAll_in.printOutInterlaced('a', m_gcAnalyzeAll.getBits()); 2224 2225 #if _SUMMARY_OUT_ 2226 m_gcAnalyzeAll_in.printSummaryOutInterlaced(); 2227 #endif 2228 } 2235 2229 2236 2230 printf("\nRVM: %.3lf\n" , xCalculateRVM()); … … 2276 2270 // Protected member functions 2277 2271 // ==================================================================================================================== 2272 2273 2274 Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, bool isField ) 2275 { 2276 assert( iNumPicRcvd > 0 ); 2277 // Exception for the first frames 2278 if ( ( isField && (iPOCLast == 0 || iPOCLast == 1) ) || (!isField && (iPOCLast == 0)) ) 2279 { 2280 m_iGopSize = 1; 2281 } 2282 else 2283 { 2284 m_iGopSize = m_pcCfg->getGOPSize(); 2285 } 2286 assert (m_iGopSize > 0); 2287 2288 return; 2289 } 2278 2290 2279 2291 Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut ) … … 2299 2311 TComPic*& rpcPic, 2300 2312 TComPicYuv*& rpcPicYuvRecOut, 2301 Int pocCurr ) 2313 Int pocCurr, 2314 bool isField) 2302 2315 { 2303 2316 Int i; 2304 2317 // Rec. output 2305 2318 TComList<TComPicYuv*>::iterator iterPicYuvRec = rcListPicYuvRecOut.end(); 2306 for ( i = 0; i < iNumPicRcvd - iTimeOffset + 1; i++ ) 2319 2320 if (isField) 2321 { 2322 for ( i = 0; i < ( (pocCurr == 0 ) || (pocCurr == 1 ) ? (iNumPicRcvd - iTimeOffset + 1) : (iNumPicRcvd - iTimeOffset + 2) ); i++ ) 2323 { 2324 iterPicYuvRec--; 2325 } 2326 } 2327 else 2328 { 2329 for ( i = 0; i < (iNumPicRcvd - iTimeOffset + 1); i++ ) 2307 2330 { 2308 2331 iterPicYuvRec--; 2309 2332 } 2310 2333 2334 } 2335 2336 if (isField) 2337 { 2338 if(pocCurr == 1) 2339 { 2340 iterPicYuvRec++; 2341 } 2342 } 2311 2343 rpcPicYuvRecOut = *(iterPicYuvRec); 2312 2344 … … 2323 2355 iterPic++; 2324 2356 } 2325 2357 2358 #if !H_MV 2359 assert( rpcPic != NULL ); 2360 #endif 2326 2361 assert (rpcPic->getPOC() == pocCurr); 2327 2362 … … 2642 2677 } 2643 2678 2679 2680 Void reinterlace(Pel* top, Pel* bottom, Pel* dst, UInt stride, UInt width, UInt height, bool isTff) 2681 { 2682 2683 for (Int y = 0; y < height; y++) 2684 { 2685 for (Int x = 0; x < width; x++) 2686 { 2687 dst[x] = isTff ? (UChar) top[x] : (UChar) bottom[x]; 2688 dst[stride+x] = isTff ? (UChar) bottom[x] : (UChar) top[x]; 2689 } 2690 top += stride; 2691 bottom += stride; 2692 dst += stride*2; 2693 } 2694 } 2695 2696 2697 Void TEncGOP::xCalculateInterlacedAddPSNR( TComPic* pcPicOrgTop, TComPic* pcPicOrgBottom, TComPicYuv* pcPicRecTop, TComPicYuv* pcPicRecBottom, const AccessUnit& accessUnit, Double dEncTime ) 2698 { 2699 #if H_MV 2700 assert( 0 ); // Field coding and MV need to be aligned. 2701 #else 2702 Int x, y; 2703 2704 UInt64 uiSSDY_in = 0; 2705 UInt64 uiSSDU_in = 0; 2706 UInt64 uiSSDV_in = 0; 2707 2708 Double dYPSNR_in = 0.0; 2709 Double dUPSNR_in = 0.0; 2710 Double dVPSNR_in = 0.0; 2711 2712 /*------ INTERLACED PSNR -----------*/ 2713 2714 /* Luma */ 2715 2716 Pel* pOrgTop = pcPicOrgTop->getPicYuvOrg()->getLumaAddr(); 2717 Pel* pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getLumaAddr(); 2718 Pel* pRecTop = pcPicRecTop->getLumaAddr(); 2719 Pel* pRecBottom = pcPicRecBottom->getLumaAddr(); 2720 2721 Int iWidth; 2722 Int iHeight; 2723 Int iStride; 2724 2725 iWidth = pcPicOrgTop->getPicYuvOrg()->getWidth () - m_pcEncTop->getPad(0); 2726 iHeight = pcPicOrgTop->getPicYuvOrg()->getHeight() - m_pcEncTop->getPad(1); 2727 iStride = pcPicOrgTop->getPicYuvOrg()->getStride(); 2728 Int iSize = iWidth*iHeight; 2729 bool isTff = pcPicOrgTop->isTopField(); 2730 2731 TComPicYuv* pcOrgInterlaced = new TComPicYuv; 2732 pcOrgInterlaced->create( iWidth, iHeight << 1, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 2733 2734 TComPicYuv* pcRecInterlaced = new TComPicYuv; 2735 pcRecInterlaced->create( iWidth, iHeight << 1, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 2736 2737 Pel* pOrgInterlaced = pcOrgInterlaced->getLumaAddr(); 2738 Pel* pRecInterlaced = pcRecInterlaced->getLumaAddr(); 2739 2740 //=== Interlace fields ==== 2741 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 2742 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 2743 2744 //===== calculate PSNR ===== 2745 for( y = 0; y < iHeight << 1; y++ ) 2746 { 2747 for( x = 0; x < iWidth; x++ ) 2748 { 2749 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 2750 uiSSDY_in += iDiff * iDiff; 2751 } 2752 pOrgInterlaced += iStride; 2753 pRecInterlaced += iStride; 2754 } 2755 2756 /*Chroma*/ 2757 2758 iHeight >>= 1; 2759 iWidth >>= 1; 2760 iStride >>= 1; 2761 2762 pOrgTop = pcPicOrgTop->getPicYuvOrg()->getCbAddr(); 2763 pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getCbAddr(); 2764 pRecTop = pcPicRecTop->getCbAddr(); 2765 pRecBottom = pcPicRecBottom->getCbAddr(); 2766 pOrgInterlaced = pcOrgInterlaced->getCbAddr(); 2767 pRecInterlaced = pcRecInterlaced->getCbAddr(); 2768 2769 //=== Interlace fields ==== 2770 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 2771 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 2772 2773 //===== calculate PSNR ===== 2774 for( y = 0; y < iHeight << 1; y++ ) 2775 { 2776 for( x = 0; x < iWidth; x++ ) 2777 { 2778 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 2779 uiSSDU_in += iDiff * iDiff; 2780 } 2781 pOrgInterlaced += iStride; 2782 pRecInterlaced += iStride; 2783 } 2784 2785 pOrgTop = pcPicOrgTop->getPicYuvOrg()->getCrAddr(); 2786 pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getCrAddr(); 2787 pRecTop = pcPicRecTop->getCrAddr(); 2788 pRecBottom = pcPicRecBottom->getCrAddr(); 2789 pOrgInterlaced = pcOrgInterlaced->getCrAddr(); 2790 pRecInterlaced = pcRecInterlaced->getCrAddr(); 2791 2792 //=== Interlace fields ==== 2793 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 2794 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 2795 2796 //===== calculate PSNR ===== 2797 for( y = 0; y < iHeight << 1; y++ ) 2798 { 2799 for( x = 0; x < iWidth; x++ ) 2800 { 2801 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 2802 uiSSDV_in += iDiff * iDiff; 2803 } 2804 pOrgInterlaced += iStride; 2805 pRecInterlaced += iStride; 2806 } 2807 2808 Int maxvalY = 255 << (g_bitDepthY-8); 2809 Int maxvalC = 255 << (g_bitDepthC-8); 2810 Double fRefValueY = (Double) maxvalY * maxvalY * iSize*2; 2811 Double fRefValueC = (Double) maxvalC * maxvalC * iSize*2 / 4.0; 2812 dYPSNR_in = ( uiSSDY_in ? 10.0 * log10( fRefValueY / (Double)uiSSDY_in ) : 99.99 ); 2813 dUPSNR_in = ( uiSSDU_in ? 10.0 * log10( fRefValueC / (Double)uiSSDU_in ) : 99.99 ); 2814 dVPSNR_in = ( uiSSDV_in ? 10.0 * log10( fRefValueC / (Double)uiSSDV_in ) : 99.99 ); 2815 2816 /* calculate the size of the access unit, excluding: 2817 * - any AnnexB contributions (start_code_prefix, zero_byte, etc.,) 2818 * - SEI NAL units 2819 */ 2820 UInt numRBSPBytes = 0; 2821 for (AccessUnit::const_iterator it = accessUnit.begin(); it != accessUnit.end(); it++) 2822 { 2823 UInt numRBSPBytes_nal = UInt((*it)->m_nalUnitData.str().size()); 2824 2825 if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI) 2826 numRBSPBytes += numRBSPBytes_nal; 2827 } 2828 2829 UInt uibits = numRBSPBytes * 8 ; 2830 2831 //===== add PSNR ===== 2832 m_gcAnalyzeAll_in.addResult (dYPSNR_in, dUPSNR_in, dVPSNR_in, (Double)uibits); 2833 2834 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 ); 2835 2836 pcOrgInterlaced->destroy(); 2837 delete pcOrgInterlaced; 2838 pcRecInterlaced->destroy(); 2839 delete pcRecInterlaced; 2840 #endif 2841 } 2644 2842 /** Function for deciding the nal_unit_type. 2645 2843 * \param pocCurr POC of the current picture … … 3002 3200 3003 3201 #if H_MV 3004 #if H_MV53005 3202 Void TEncGOP::xSetRefPicListModificationsMv( std::vector<TComPic*> tempPicLists[2], TComSlice* pcSlice, UInt iGOPid ) 3006 3203 { … … 3086 3283 } 3087 3284 } 3088 #else3089 Void TEncGOP::xSetRefPicListModificationsMv( TComSlice* pcSlice, UInt iGOPid )3090 {3091 Int layer = pcSlice->getLayerIdInVps( );3092 3093 if( pcSlice->getSliceType() == I_SLICE || !(pcSlice->getPPS()->getListsModificationPresentFlag()) || pcSlice->getNumActiveRefLayerPics() == 0 )3094 {3095 return;3096 }3097 3098 // analyze inter-view modifications3099 GOPEntry ge = m_pcCfg->getGOPEntry( (pcSlice->getRapPicFlag() && ( layer > 0) ) ? MAX_GOP : iGOPid );3100 assert( ge.m_numActiveRefLayerPics == pcSlice->getNumActiveRefLayerPics() );3101 3102 Int maxRefListSize = pcSlice->getNumRpsCurrTempList();3103 Int numTemporalRefs = maxRefListSize - pcSlice->getNumActiveRefLayerPics();3104 3105 for (Int li = 0; li < 2; li ++) // Loop over lists L0 and L13106 {3107 // set inter-view modifications3108 Int tempList[16];3109 for( Int k = 0; k < 16; k++ )3110 {3111 tempList[ k ] = -1;3112 }3113 3114 Bool isModified = false;3115 if ( maxRefListSize > 1 )3116 {3117 for( Int k = 0, orgIdx = numTemporalRefs; k < ge.m_numActiveRefLayerPics; k++, orgIdx++ )3118 {3119 Int targetIdx = ge.m_interViewRefPosL[ li ][ k ];3120 3121 isModified = ( targetIdx != orgIdx ) && ( targetIdx >= 0 );3122 if ( isModified )3123 {3124 assert( tempList[ targetIdx ] == -1 ); // Assert when two inter layer reference pictures are sorted to the same position3125 tempList[ targetIdx ] = orgIdx;3126 }3127 }3128 }3129 3130 TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();3131 refPicListModification->setRefPicListModificationFlagL( li, isModified );3132 3133 if( isModified )3134 {3135 Int temporalRefIdx = 0;3136 for( Int i = 0; i < pcSlice->getNumRefIdx( ( li == 0 ) ? REF_PIC_LIST_0 : REF_PIC_LIST_1 ); i++ )3137 {3138 if( tempList[i] >= 0 )3139 {3140 refPicListModification->setRefPicSetIdxL( li, i, tempList[i] );3141 }3142 else3143 {3144 refPicListModification->setRefPicSetIdxL( li, i, temporalRefIdx );3145 temporalRefIdx++;3146 }3147 }3148 }3149 }3150 }3151 #endif3152 3285 #endif 3153 3286 //! \}
Note: See TracChangeset for help on using the changeset viewer.