69 return (maxLSB - ((-poc) % maxLSB)) % maxLSB;
79 m_iLastRecoveryPicPOC = 0;
82 m_pcSliceEncoder =
NULL;
85 m_pcEntropyCoder =
NULL;
86 m_pcCavlcCoder =
NULL;
92 m_bRefreshPending = 0;
94 m_numLongTermRefPicSPS = 0;
95 ::memset(m_ltRefPicPocLsbSps, 0,
sizeof(m_ltRefPicPocLsbSps));
96 ::memset(m_ltRefPicUsedByCurrPicFlag, 0,
sizeof(m_ltRefPicUsedByCurrPicFlag));
98 m_bufferingPeriodSEIPresentInAU =
false;
100 m_associatedIRAPPOC = 0;
101 m_pcDeblockingTempPicYuv =
NULL;
112 m_bLongtermTestPictureHasBeenCoded = 0;
113 m_bLongtermTestPictureHasBeenCoded2 = 0;
118 if (m_pcDeblockingTempPicYuv)
120 m_pcDeblockingTempPicYuv->destroy();
121 delete m_pcDeblockingTempPicYuv;
122 m_pcDeblockingTempPicYuv =
NULL;
128 m_pcEncTop = pcTEncTop;
130 m_seiEncoder.
init(m_pcCfg, pcTEncTop,
this);
140 m_pcSAO = pcTEncTop->
getSAO();
151 m_pcEntropyCoder->encodeVPS(vps);
153 return (
Int)(accessUnit.back()->m_nalUnitData.str().size()) * 8;
160 m_pcEntropyCoder->encodeSPS(sps);
162 return (
Int)(accessUnit.back()->m_nalUnitData.str().size()) * 8;
170 m_pcEntropyCoder->encodePPS(pps);
172 return (
Int)(accessUnit.back()->m_nalUnitData.str().size()) * 8;
178 Int actualTotalBits = 0;
182 actualTotalBits += xWriteVPS(accessUnit, m_pcEncTop->getVPS());
187 actualTotalBits += xWriteSPS(accessUnit, slice->
getSPS());
191 actualTotalBits += xWritePPS(accessUnit, slice->
getPPS());
194 return actualTotalBits;
212 if (seiMessages.empty())
217 m_seiWriter.writeSEImessages(nalu.
m_Bitstream, seiMessages, sps,
false);
218 auPos = accessUnit.insert(auPos,
new NALUnitEBSP(nalu));
225 if (seiMessages.empty())
229 for (SEIMessages::const_iterator sei = seiMessages.begin(); sei!=seiMessages.end(); sei++ )
232 tmpMessages.push_back(*sei);
234 m_seiWriter.writeSEImessages(nalu.
m_Bitstream, tmpMessages, sps,
false);
235 auPos = accessUnit.insert(auPos,
new NALUnitEBSP(nalu));
255 AccessUnit::iterator itNalu = accessUnit.begin();
257 while ( (itNalu!=accessUnit.end())&&
271 g_HLSTraceEnable = !testWrite;
277 assert (currentMessages.size() <= 1);
279 xClearSEIs(currentMessages, !testWrite);
283 assert (currentMessages.size() <= 1);
285 xClearSEIs(currentMessages, !testWrite);
289 assert (currentMessages.size() <= 1);
291 xClearSEIs(currentMessages, !testWrite);
294 if (!duInfoSeiMessages.empty())
296 currentMessages.push_back(duInfoSeiMessages.front());
299 duInfoSeiMessages.pop_front();
302 xClearSEIs(currentMessages, !testWrite);
307 xWriteSEISeparately(
NAL_UNIT_PREFIX_SEI, currentMessages, accessUnit, itNalu, temporalId, sps);
308 xClearSEIs(currentMessages, !testWrite);
311 xWriteSEISeparately(
NAL_UNIT_PREFIX_SEI, localMessages, accessUnit, itNalu, temporalId, sps);
312 xClearSEIs(localMessages, !testWrite);
325 assert (picTimingSEIs.size() < 2);
329 xWriteLeadingSEIOrdered(seiMessages, duInfoSeiMessages, testAU, temporalId, sps,
true);
331 xUpdateDuData(testAU, duData);
332 xUpdateTimingSEI(picTiming, duData, sps);
333 xUpdateDuInfoSEI(duInfoSeiMessages, picTiming);
335 xWriteLeadingSEIOrdered(seiMessages, duInfoSeiMessages, accessUnit, temporalId, sps,
false);
343 AccessUnit::iterator pos = accessUnit.end();
355 AccessUnit::iterator nalu = accessUnit.begin();
358 while (naluIdx < duData[0].accumNalsDU && nalu!=accessUnit.end())
364 SEIMessages::iterator duSEI = duInfoSeiMessages.begin();
366 for (
Int duIdx = 1; duIdx < duData.size(); duIdx++)
368 if (duSEI == duInfoSeiMessages.end())
376 tmpSEI.push_back(*duSEI);
380 while ((naluIdx < duData[duIdx].accumNalsDU) && nalu!=accessUnit.end())
396 if(m_pcCfg->getActiveParameterSetsSEIEnabled())
399 m_seiEncoder.initSEIActiveParameterSets (sei, m_pcCfg->getVPS(), sps);
400 seiMessages.push_back(sei);
403 if(m_pcCfg->getFramePackingArrangementSEIEnabled())
406 m_seiEncoder.initSEIFramePacking (sei, m_iNumPicCoded);
407 seiMessages.push_back(sei);
410 if(m_pcCfg->getSegmentedRectFramePackingArrangementSEIEnabled())
413 m_seiEncoder.initSEISegmentedRectFramePacking(sei);
414 seiMessages.push_back(sei);
417 if (m_pcCfg->getDisplayOrientationSEIAngle())
420 m_seiEncoder.initSEIDisplayOrientation(sei);
421 seiMessages.push_back(sei);
424 if(m_pcCfg->getToneMappingInfoSEIEnabled())
427 m_seiEncoder.initSEIToneMappingInfo (sei);
428 seiMessages.push_back(sei);
431 if(m_pcCfg->getTMCTSSEIEnabled())
434 m_seiEncoder.initSEITempMotionConstrainedTileSets(sei, pps);
435 seiMessages.push_back(sei);
438 if(m_pcCfg->getTimeCodeSEIEnabled())
441 m_seiEncoder.initSEITimeCode(seiTimeCode);
442 seiMessages.push_back(seiTimeCode);
445 if(m_pcCfg->getKneeSEIEnabled())
448 m_seiEncoder.initSEIKneeFunctionInfo(sei);
449 seiMessages.push_back(sei);
453 if (m_pcCfg->getCcvSEIEnabled())
456 m_seiEncoder.initSEIContentColourVolume(seiContentColourVolume);
457 seiMessages.push_back(seiContentColourVolume);
461 #if ERP_SR_OV_SEI_MESSAGE
462 if (m_pcCfg->getErpSEIEnabled())
465 m_seiEncoder.initSEIErp(sei);
466 seiMessages.push_back(sei);
469 if (m_pcCfg->getSphereRotationSEIEnabled())
472 m_seiEncoder.initSEISphereRotation(sei);
473 seiMessages.push_back(sei);
476 if (m_pcCfg->getOmniViewportSEIEnabled())
479 m_seiEncoder.initSEIOmniViewport(sei);
480 seiMessages.push_back(sei);
484 if (m_pcCfg->getCmpSEIEnabled())
487 m_seiEncoder.initSEICubemapProjection(seiCubemapProjection);
488 seiMessages.push_back(seiCubemapProjection);
492 if (m_pcCfg->getRwpSEIEnabled())
495 m_seiEncoder.initSEIRegionWisePacking(seiRegionWisePacking);
496 seiMessages.push_back(seiRegionWisePacking);
500 if(m_pcCfg->getMasteringDisplaySEI().colourVolumeSEIEnabled)
505 seiMessages.push_back(sei);
507 if(m_pcCfg->getChromaResamplingFilterHintEnabled())
510 m_seiEncoder.initSEIChromaResamplingFilterHint(seiChromaResamplingFilterHint, m_pcCfg->getChromaResamplingHorFilterIdc(), m_pcCfg->getChromaResamplingVerFilterIdc());
511 seiMessages.push_back(seiChromaResamplingFilterHint);
513 if(m_pcCfg->getSEIAlternativeTransferCharacteristicsSEIEnable())
516 m_seiEncoder.initSEIAlternativeTransferCharacteristics(seiAlternativeTransferCharacteristics);
517 seiMessages.push_back(seiAlternativeTransferCharacteristics);
529 m_seiEncoder.initSEIBufferingPeriod(bufferingPeriodSEI, slice);
530 seiMessages.push_back(bufferingPeriodSEI);
531 m_bufferingPeriodSEIPresentInAU =
true;
533 if (m_pcCfg->getScalableNestingSEIEnabled())
536 bufferingPeriodSEI->
copyTo(*bufferingPeriodSEIcopy);
537 nestedSeiMessages.push_back(bufferingPeriodSEIcopy);
541 if (picInGOP ==0 && m_pcCfg->getSOPDescriptionSEIEnabled() )
544 m_seiEncoder.initSEISOPDescription(sopDescriptionSEI, slice, picInGOP, m_iLastIDR, m_iGopSize);
545 seiMessages.push_back(sopDescriptionSEI);
550 if( m_pcEncTop->getGradualDecodingRefreshInfoEnabled() && !slice->
getRapPicFlag() )
555 seiMessages.push_back(gradualDecodingRefreshInfoSEI);
559 m_seiEncoder.initSEIRecoveryPoint(recoveryPointSEI, slice);
560 seiMessages.push_back(recoveryPointSEI);
562 if (m_pcCfg->getTemporalLevel0IndexSEIEnabled())
565 m_seiEncoder.initTemporalLevel0IndexSEI(temporalLevel0IndexSEI, slice);
566 seiMessages.push_back(temporalLevel0IndexSEI);
569 if( m_pcEncTop->getNoDisplaySEITLayer() && ( slice->
getTLayer() >= m_pcEncTop->getNoDisplaySEITLayer() ) )
573 seiMessages.push_back(seiNoDisplay);
577 if (!m_pcCfg->getColourRemapInfoSEIFileRoot().empty())
580 const Bool success = m_seiEncoder.initSEIColourRemappingInfo(seiColourRemappingInfo, slice->
getPOC() );
584 seiMessages.push_back(seiColourRemappingInfo);
588 delete seiColourRemappingInfo;
593 if (!m_pcCfg->getRegionalNestingSEIFileRoot().empty())
596 const Bool success = m_seiEncoder.initSEIRegionalNesting(seiRegionalNesting, slice->
getPOC() );
600 seiMessages.push_back(seiRegionalNesting);
604 delete seiRegionalNesting;
613 while (!nestedSeiMessages.empty())
615 SEI* sei=nestedSeiMessages.front();
616 nestedSeiMessages.pop_front();
617 tmpMessages.push_back(sei);
619 m_seiEncoder.initSEIScalableNesting(nestingSEI, tmpMessages);
620 seiMessages.push_back(nestingSEI);
631 if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) &&
635 Int picSptDpbOutputDuDelay = 0;
649 if(m_pcCfg->getEfficientFieldIRAPEnabled() && IRAPGOPid > 0 && IRAPGOPid < m_iGopSize)
656 if( m_pcCfg->getDecodingUnitInfoSEIEnabled() )
660 if (m_bufferingPeriodSEIPresentInAU)
662 m_lastBPSEI = m_totalCoded;
674 for( i = 0; i < numDU; i ++ )
676 pictureTimingSEI->
m_numNalusInDuMinus1[ i ] = ( i == 0 ) ? ( duData[i].accumNalsDU - 1 ) : ( duData[i].accumNalsDU- duData[i-1].accumNalsDU - 1 );
681 rDuCpbRemovalDelayMinus1[ 0 ] = 0;
685 rDuCpbRemovalDelayMinus1[ numDU - 1 ] = 0;
689 for( i = ( numDU - 2 ); i >= 0; i -- )
692 if( (
UInt)ui64Tmp > maxDiff )
700 for( i = ( numDU - 2 ); i >= 0; i -- )
705 if( (
UInt)ui64Tmp > maxDiff )
707 if(uiPrev >= maxDiff - tmp)
709 ui64Tmp = uiPrev + 1;
712 else ui64Tmp = maxDiff - tmp + 1;
714 rDuCpbRemovalDelayMinus1[ i ] = (
UInt)ui64Tmp - uiPrev - 1;
715 if( (
Int)rDuCpbRemovalDelayMinus1[ i ] < 0 )
717 rDuCpbRemovalDelayMinus1[ i ] = 0;
719 else if (tmp > 0 && flag == 1)
723 accum += rDuCpbRemovalDelayMinus1[ i ] + 1;
729 if( m_pcCfg->getPictureTimingSEIEnabled() )
732 seiMessages.push_back(pictureTimingSEI);
734 if ( m_pcCfg->getScalableNestingSEIEnabled() )
737 pictureTimingSEI->
copyTo(*pictureTimingSEIcopy);
738 nestedSeiMessages.push_back(pictureTimingSEIcopy);
752 duInfoSeiMessages.push_back(duInfoSEI);
756 if( !m_pcCfg->getPictureTimingSEIEnabled() && pictureTimingSEI )
758 delete pictureTimingSEI;
770 UInt numNalUnits = (
UInt)testAU.size();
771 UInt numRBSPBytes = 0;
772 for (AccessUnit::const_iterator it = testAU.begin(); it != testAU.end(); it++)
774 numRBSPBytes +=
UInt((*it)->m_nalUnitData.str().size());
776 duData[0].accumBitsDU += ( numRBSPBytes << 3 );
777 duData[0].accumNalsDU += numNalUnits;
781 for (
Int i=1; i<duData.size(); i++)
783 if (m_pcCfg->getDecodingUnitInfoSEIEnabled())
786 numRBSPBytes += ( 5 << 3 );
788 duData[i].accumBitsDU += numRBSPBytes;
789 duData[i].accumNalsDU += numNalUnits;
795 duData.back().accumBitsDU += ( 20 << 3 );
796 duData.back().accumNalsDU += 1;
802 if (!pictureTimingSEI)
817 for( i = 0; i < numDU; i ++ )
819 pictureTimingSEI->
m_numNalusInDuMinus1[ i ] = ( i == 0 ) ? ( duData[i].accumNalsDU - 1 ) : ( duData[i].accumNalsDU- duData[i-1].accumNalsDU - 1 );
824 rDuCpbRemovalDelayMinus1[ 0 ] = 0;
828 rDuCpbRemovalDelayMinus1[ numDU - 1 ] = 0;
832 for( i = ( numDU - 2 ); i >= 0; i -- )
835 if( (
UInt)ui64Tmp > maxDiff )
843 for( i = ( numDU - 2 ); i >= 0; i -- )
848 if( (
UInt)ui64Tmp > maxDiff )
850 if(uiPrev >= maxDiff - tmp)
852 ui64Tmp = uiPrev + 1;
855 else ui64Tmp = maxDiff - tmp + 1;
857 rDuCpbRemovalDelayMinus1[ i ] = (
UInt)ui64Tmp - uiPrev - 1;
858 if( (
Int)rDuCpbRemovalDelayMinus1[ i ] < 0 )
860 rDuCpbRemovalDelayMinus1[ i ] = 0;
862 else if (tmp > 0 && flag == 1)
866 accum += rDuCpbRemovalDelayMinus1[ i ] + 1;
874 if (duInfoSeiMessages.empty() || (pictureTimingSEI ==
NULL))
881 for (SEIMessages::iterator du = duInfoSeiMessages.begin(); du!= duInfoSeiMessages.end(); du++)
900 const Int rawBits = paddedWidth * paddedHeight *
902 const std::size_t threshold = (32/3)*numBytesInVclNalUnits + (rawBits/32);
903 if (binCountsInNalUnits >= threshold)
906 const std::size_t targetNumBytesInVclNalUnits = ((binCountsInNalUnits - (rawBits/32))*3+31)/32;
908 if (targetNumBytesInVclNalUnits>numBytesInVclNalUnits)
910 const std::size_t numberOfAdditionalBytesNeeded=targetNumBytesInVclNalUnits - numBytesInVclNalUnits;
911 const std::size_t numberOfAdditionalCabacZeroWords=(numberOfAdditionalBytesNeeded+2)/3;
912 const std::size_t numberOfAdditionalCabacZeroBytes=numberOfAdditionalCabacZeroWords*3;
913 if (cabacZeroWordPaddingEnabled)
915 std::vector<UChar> zeroBytesPadding(numberOfAdditionalCabacZeroBytes,
UChar(0));
916 for(std::size_t i=0; i<numberOfAdditionalCabacZeroWords; i++)
918 zeroBytesPadding[i*3+2]=3;
920 nalUnitData.write(reinterpret_cast<const TChar*>(&(zeroBytesPadding[0])), numberOfAdditionalCabacZeroBytes);
921 printf(
"Adding %d bytes of padding\n",
UInt(numberOfAdditionalCabacZeroWords*3));
925 printf(
"Standard would normally require adding %d bytes of padding\n",
UInt(numberOfAdditionalCabacZeroWords*3));
941 IRAPtoReorder(false),
942 swapIRAPForward(false)
947 Int adjustGOPid(
const Int gopID);
948 Int restoreGOPid(
const Int gopID);
957 for (
Int iGOPid=0; iGOPid < gopSize; iGOPid++ )
964 else if(POCLast == 1 && isField)
977 if(pocCurr%2 == 0 && iGOPid < gopSize-1 && pCfg->getGOPEntry(iGOPid).m_POC == pCfg->
getGOPEntry(iGOPid+1).
m_POC-1)
980 IRAPtoReorder =
true;
981 swapIRAPForward =
true;
988 IRAPtoReorder =
true;
989 swapIRAPForward =
false;
1003 if(GOPid == IRAPGOPid)
1005 return IRAPGOPid +1;
1007 else if(GOPid == IRAPGOPid +1)
1014 if(GOPid == IRAPGOPid -1)
1018 else if(GOPid == IRAPGOPid)
1020 return IRAPGOPid -1;
1033 if(GOPid == IRAPGOPid)
1035 IRAPtoReorder =
false;
1036 return IRAPGOPid +1;
1038 else if(GOPid == IRAPGOPid +1)
1045 if(GOPid == IRAPGOPid)
1047 return IRAPGOPid -1;
1049 else if(GOPid == IRAPGOPid -1)
1051 IRAPtoReorder =
false;
1060 #if X0038_LAMBDA_FROM_QP_CAPABILITY
1063 const Int refIdx = 0;
1069 static UInt calculateCollocatedFromL1Flag(
TEncCfg *pCfg,
const Int GOPid,
const Int gopSize)
1071 Int iCloseLeft=1, iCloseRight=-1;
1075 if(iRef>0&&(iRef<iCloseRight||iCloseRight==-1))
1079 else if(iRef<0&&(iRef>iCloseLeft||iCloseLeft==1))
1093 iCloseLeft+=gopSize;
1096 Int iLeftQP=0, iRightQP=0;
1097 for(
Int i=0; i<gopSize; i++)
1108 if(iCloseRight>-1&&iRightQP<iLeftQP)
1123 const TChar *decodedPictureHashModeName;
1127 decodedPictureHashModeName =
"MD5";
1130 decodedPictureHashModeName =
"CRC";
1133 decodedPictureHashModeName =
"Checksum";
1136 decodedPictureHashModeName =
NULL;
1139 if (decodedPictureHashModeName !=
NULL)
1141 if (digestStr.empty())
1143 printf(
" [%s:%s]", decodedPictureHashModeName,
"?");
1147 printf(
" [%s:%s]", decodedPictureHashModeName, digestStr.c_str());
1170 AccessUnit::iterator itLocationToPushSliceHeaderNALU;
1172 xInitGOP( iPOCLast, iNumPicRcvd, isField );
1179 std::deque<DUData> duData;
1183 if (m_pcCfg->getEfficientFieldIRAPEnabled())
1185 effFieldIRAPMap.
initialize(isField, m_iGopSize, iPOCLast, iNumPicRcvd, m_iLastIDR,
this, m_pcCfg);
1189 for (
Int iGOPid=0; iGOPid < m_iGopSize; iGOPid++ )
1191 m_pcCfg->setEncodedFlag(iGOPid,
false);
1194 for (
Int iGOPid=0; iGOPid < m_iGopSize; iGOPid++ )
1196 if (m_pcCfg->getEfficientFieldIRAPEnabled())
1202 clock_t iBeforeTime = clock();
1204 #if !X0038_LAMBDA_FROM_QP_CAPABILITY
1205 UInt uiColDir = calculateCollocatedFromL1Flag(m_pcCfg, iGOPid, m_iGopSize);
1217 else if(iPOCLast == 1 && isField)
1224 pocCurr = iPOCLast - iNumPicRcvd + m_pcCfg->getGOPEntry(iGOPid).m_POC - ((isField && m_iGopSize>1) ? 1:0);
1225 iTimeOffset = m_pcCfg->getGOPEntry(iGOPid).m_POC;
1228 if(pocCurr>=m_pcCfg->getFramesToBeEncoded())
1230 if (m_pcCfg->getEfficientFieldIRAPEnabled())
1239 m_iLastIDR = pocCurr;
1243 AccessUnit& accessUnit = accessUnitsInGOP.back();
1244 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr, isField );
1246 #if REDUCED_ENCODER_MEMORY
1253 m_pcSliceEncoder->setSliceIdx(0);
1256 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iGOPid, pcSlice, isField );
1273 pcSlice->
setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR, isField));
1292 if (m_pcCfg->getEfficientFieldIRAPEnabled())
1302 m_associatedIRAPPOC = pocCurr;
1308 pcSlice->
decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic, m_pcCfg->getEfficientFieldIRAPEnabled());
1309 m_pcEncTop->selectReferencePictureSet(pcSlice, pocCurr, iGOPid);
1310 if (!m_pcCfg->getEfficientFieldIRAPEnabled())
1320 m_associatedIRAPPOC = pocCurr;
1356 for(
Int ii=iGOPid+1;(ii<m_pcCfg->getGOPSize() && isSTSA==
true);ii++)
1358 Int lTid= m_pcCfg->getGOPEntry(ii).m_temporalId;
1368 for(kk=0;kk<m_pcCfg->getGOPSize();kk++)
1370 if(m_pcCfg->getGOPEntry(kk).m_POC==tPoc)
1375 Int tTid=m_pcCfg->getGOPEntry(kk).m_temporalId;
1398 arrangeLongtermPicturesInRPS(pcSlice, rcListPic);
1417 #if X0038_LAMBDA_FROM_QP_CAPABILITY
1423 Bool bLowDelay =
true;
1449 #if !X0038_LAMBDA_FROM_QP_CAPABILITY
1450 uiColDir = 1-uiColDir;
1458 if (m_pcEncTop->getTMVPModeId() == 2)
1470 else if (m_pcEncTop->getTMVPModeId() == 1)
1482 m_pcSliceEncoder->setSearchRange(pcSlice);
1485 Bool bGPBcheck=
false;
1513 Int actualHeadBits = 0;
1514 Int actualTotalBits = 0;
1515 Int estimatedBits = 0;
1516 Int tmpBitsBeforeWriting = 0;
1517 if ( m_pcCfg->getUseRateCtrl() )
1519 Int frameLevel = m_pcRateCtrl->getRCSeq()->getGOPID2Level( iGOPid );
1524 m_pcRateCtrl->initRCPic( frameLevel );
1525 estimatedBits = m_pcRateCtrl->getRCPic()->getTargetBits();
1527 if (m_pcRateCtrl->getCpbSaturationEnabled() && frameLevel != 0)
1529 Int estimatedCpbFullness = m_pcRateCtrl->getCpbState() + m_pcRateCtrl->getBufferingRate();
1532 if (estimatedCpbFullness - estimatedBits > (
Int)(m_pcRateCtrl->getCpbSize()*0.9f))
1534 estimatedBits = estimatedCpbFullness - (
Int)(m_pcRateCtrl->getCpbSize()*0.9f);
1537 estimatedCpbFullness -= m_pcRateCtrl->getBufferingRate();
1539 if (estimatedCpbFullness - estimatedBits < m_pcRateCtrl->getRCPic()->getLowerBound())
1541 estimatedBits = max(200, estimatedCpbFullness - m_pcRateCtrl->getRCPic()->getLowerBound());
1544 m_pcRateCtrl->getRCPic()->setTargetBits(estimatedBits);
1547 Int sliceQP = m_pcCfg->getInitialQP();
1548 if ( ( pcSlice->
getPOC() == 0 && m_pcCfg->getInitialQP() > 0 ) || ( frameLevel == 0 && m_pcCfg->getForceIntraQP() ) )
1550 Int NumberBFrames = ( m_pcCfg->getGOPSize() - 1 );
1552 Double dQPFactor = 0.57*dLambda_scale;
1554 Int bitdepth_luma_qp_scale = 0;
1555 Double qp_temp = (
Double) sliceQP + bitdepth_luma_qp_scale - SHIFT_QP;
1556 lambda = dQPFactor*pow( 2.0, qp_temp/3.0 );
1558 else if ( frameLevel == 0 )
1560 m_pcSliceEncoder->calCostSliceI(pcPic);
1562 if ( m_pcCfg->getIntraPeriod() != 1 )
1564 Int bits = m_pcRateCtrl->getRCSeq()->getLeftAverageBits();
1565 bits = m_pcRateCtrl->getRCPic()->getRefineBitsForIntra( bits );
1567 if (m_pcRateCtrl->getCpbSaturationEnabled() )
1569 Int estimatedCpbFullness = m_pcRateCtrl->getCpbState() + m_pcRateCtrl->getBufferingRate();
1572 if (estimatedCpbFullness - bits > (
Int)(m_pcRateCtrl->getCpbSize()*0.9f))
1574 bits = estimatedCpbFullness - (
Int)(m_pcRateCtrl->getCpbSize()*0.9f);
1577 estimatedCpbFullness -= m_pcRateCtrl->getBufferingRate();
1579 if (estimatedCpbFullness - bits < m_pcRateCtrl->getRCPic()->getLowerBound())
1581 bits = estimatedCpbFullness - m_pcRateCtrl->getRCPic()->getLowerBound();
1589 m_pcRateCtrl->getRCPic()->setTargetBits( bits );
1592 list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList();
1593 m_pcRateCtrl->getRCPic()->getLCUInitTargetBits();
1594 lambda = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture, pcSlice->
getSliceType());
1595 sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture );
1599 list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList();
1600 lambda = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture, pcSlice->
getSliceType());
1601 sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture );
1605 m_pcRateCtrl->getRCPic()->setPicEstQP( sliceQP );
1607 m_pcSliceEncoder->resetQP( pcPic, sliceQP, lambda );
1610 UInt uiNumSliceSegments = 1;
1615 const Int numSubstreams = numSubstreamRows * numSubstreamsColumns;
1616 std::vector<TComOutputBitstream> substreamsOut(numSubstreams);
1624 for(
UInt nextCtuTsAddr = 0; nextCtuTsAddr < numberOfCtusInFrame; )
1626 m_pcSliceEncoder->precompressSlice( pcPic );
1627 m_pcSliceEncoder->compressSlice ( pcPic,
false,
false );
1630 if (curSliceSegmentEnd < numberOfCtusInFrame)
1637 m_pcSliceEncoder->setSliceIdx ( uiNumSliceSegments );
1638 pcSlice = pcPic->
getSlice ( uiNumSliceSegments );
1639 assert(pcSlice->
getPPS()!=0);
1642 if (bNextSegmentIsDependentSlice)
1655 uiNumSliceSegments ++;
1657 nextCtuTsAddr = curSliceSegmentEnd;
1667 m_pcSAO->getPreDBFStatistics(pcPic);
1672 m_pcLoopFilter->setCfg(bLFCrossTileBoundary);
1673 if ( m_pcCfg->getDeblockingFilterMetric() )
1675 if ( m_pcCfg->getDeblockingFilterMetric()==2 )
1677 applyDeblockingFilterParameterSelection(pcPic, uiNumSliceSegments, iGOPid);
1681 applyDeblockingFilterMetric(pcPic, uiNumSliceSegments);
1684 m_pcLoopFilter->loopFilterPic( pcPic );
1688 m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder );
1691 #if JCTVC_Y0038_PARAMS
1693 bool writePS = m_bSeqFirst || (m_pcCfg->getReWriteParamSetsFlag() && (pcSlice->
isIRAP()));
1698 actualTotalBits += xWriteParameterSets(accessUnit, pcSlice, writePS);
1702 actualTotalBits += xWriteParameterSets(accessUnit, pcSlice, m_bSeqFirst);
1708 assert(leadingSeiMessages.empty());
1709 xCreateIRAPLeadingSEIMessages(leadingSeiMessages, pcSlice->
getSPS(), pcSlice->
getPPS());
1711 m_bSeqFirst =
false;
1713 if (m_pcCfg->getAccessUnitDelimiter())
1715 xWriteAccessUnitDelimiter(accessUnit, pcSlice);
1719 m_bufferingPeriodSEIPresentInAU =
false;
1721 xCreatePerPictureSEIMessages(iGOPid, leadingSeiMessages, nestedSeiMessages, pcSlice);
1724 m_pcEntropyCoder->setBitstream(
NULL);
1733 m_pcEncTop->getRDGoOnSbacCoder()->setBitstream(&tempBitCounter);
1734 m_pcSAO->initRDOCabacCoder(m_pcEncTop->getRDGoOnSbacCoder(), pcSlice);
1736 m_pcCfg->getTestSAODisableAtPictureLevel(),
1737 m_pcCfg->getSaoEncodingRate(),
1738 m_pcCfg->getSaoEncodingRateChroma(),
1739 m_pcCfg->getSaoCtuBoundary(),
1740 m_pcCfg->getSaoResetEncoderStateAfterIRAP());
1741 m_pcSAO->PCMLFDisableProcess(pcPic);
1742 m_pcEncTop->getRDGoOnSbacCoder()->setBitstream(
NULL);
1745 for(
Int s=0; s< uiNumSliceSegments; s++)
1754 std::size_t binCountsInNalUnits = 0;
1755 std::size_t numBytesInVclNalUnits = 0;
1759 pcSlice = pcPic->
getSlice(sliceIdxCount);
1765 m_pcSliceEncoder->setSliceIdx(sliceIdxCount);
1770 for (
UInt ui = 0 ; ui < numSubstreams; ui++ )
1772 substreamsOut[ui].clear();
1775 m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder );
1776 m_pcEntropyCoder->resetEntropy ( pcSlice );
1779 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
1801 tmpBitsBeforeWriting = m_pcEntropyCoder->getNumberOfWrittenBits();
1802 m_pcEntropyCoder->encodeSliceHeader(pcSlice);
1803 actualHeadBits += ( m_pcEntropyCoder->getNumberOfWrittenBits() - tmpBitsBeforeWriting );
1809 UInt numBinsCoded = 0;
1810 m_pcSliceEncoder->encodeSlice(pcPic, &(substreamsOut[0]), numBinsCoded);
1811 binCountsInNalUnits+=numBinsCoded;
1818 m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder );
1819 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
1820 m_pcEntropyCoder->encodeTilesWPPEntryPoint( pcSlice );
1826 for (
UInt ui = 0 ; ui < numSubstreamsToCode; ui++ )
1828 pcOut->
addSubstream(&(substreamsOut[ui+numZeroSubstreamsAtStartOfSlice]));
1834 Bool bNALUAlignedWrittenToList =
false;
1835 xAttachSliceDataToNalUnit(nalu, pcBitstreamRedirect);
1837 actualTotalBits +=
UInt(accessUnit.back()->m_nalUnitData.str().size()) * 8;
1838 numBytesInVclNalUnits += (std::size_t)(accessUnit.back()->m_nalUnitData.str().size());
1839 bNALUAlignedWrittenToList =
true;
1841 if (!bNALUAlignedWrittenToList)
1843 nalu.m_Bitstream.writeAlignZero();
1847 if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) &&
1854 UInt numRBSPBytes = 0;
1855 for (AccessUnit::const_iterator it = accessUnit.begin(); it != accessUnit.end(); it++)
1857 numRBSPBytes +=
UInt((*it)->m_nalUnitData.str().size());
1860 duData.push_back(
DUData());
1861 duData.back().accumBitsDU = ( numRBSPBytes << 3 );
1862 duData.back().accumNalsDU = numNalus;
1867 cabac_zero_word_padding(pcSlice, pcPic, binCountsInNalUnits, numBytesInVclNalUnits, accessUnit.back()->m_nalUnitData, m_pcCfg->getCabacZeroWordPaddingEnabled());
1872 Double dEncTime = (
Double)(clock()-iBeforeTime) / CLOCKS_PER_SEC;
1874 std::string digestStr;
1878 m_seiEncoder.initDecodedPictureHashSEI(decodedPictureHashSei, pcPic, digestStr, pcSlice->
getSPS()->
getBitDepths());
1879 trailingSeiMessages.push_back(decodedPictureHashSei);
1882 m_pcCfg->setEncodedFlag(iGOPid,
true);
1885 #if JVET_F0064_MSSSIM
1886 xCalculateAddPSNRs( isField, isTff, iGOPid, pcPic, accessUnit, rcListPic, dEncTime, snr_conversion, printFrameMSE, printMSSSIM, &PSNR_Y );
1888 xCalculateAddPSNRs( isField, isTff, iGOPid, pcPic, accessUnit, rcListPic, dEncTime, snr_conversion, printFrameMSE, &PSNR_Y );
1892 if( m_pcCfg->getSEIGreenMetadataInfoSEIEnable() && pcSlice->
getPOC() == ( m_pcCfg->getFramesToBeEncoded() - 1 ) )
1895 m_seiEncoder.initSEIGreenMetadataInfo(seiGreenMetadataInfo, (
UInt)(PSNR_Y * 100 + 0.5));
1896 trailingSeiMessages.push_back(seiGreenMetadataInfo);
1899 xWriteTrailingSEIMessages(trailingSeiMessages, accessUnit, pcSlice->
getTLayer(), pcSlice->
getSPS());
1901 printHash(m_pcCfg->getDecodedPictureHashSEIType(), digestStr);
1903 if ( m_pcCfg->getUseRateCtrl() )
1905 Double avgQP = m_pcRateCtrl->getRCPic()->calAverageQP();
1906 Double avgLambda = m_pcRateCtrl->getRCPic()->calAverageLambda();
1907 if ( avgLambda < 0.0 )
1912 m_pcRateCtrl->getRCPic()->updateAfterPicture( actualHeadBits, actualTotalBits, avgQP, avgLambda, pcSlice->
getSliceType());
1913 m_pcRateCtrl->getRCPic()->addToPictureLsit( m_pcRateCtrl->getPicList() );
1915 m_pcRateCtrl->getRCSeq()->updateAfterPic( actualTotalBits );
1918 m_pcRateCtrl->getRCGOP()->updateAfterPicture( actualTotalBits );
1922 m_pcRateCtrl->getRCGOP()->updateAfterPicture( estimatedBits );
1924 if (m_pcRateCtrl->getCpbSaturationEnabled())
1926 m_pcRateCtrl->updateCpbState(actualTotalBits);
1927 printf(
" [CPB %6d bits]", m_pcRateCtrl->getCpbState());
1931 xCreatePictureTimingSEI(m_pcCfg->getEfficientFieldIRAPEnabled()?effFieldIRAPMap.
GetIRAPGOPid():0, leadingSeiMessages, nestedSeiMessages, duInfoSeiMessages, pcSlice, isField, duData);
1932 if (m_pcCfg->getScalableNestingSEIEnabled())
1934 xCreateScalableNestingSEI (leadingSeiMessages, nestedSeiMessages);
1936 xWriteLeadingSEIMessages(leadingSeiMessages, duInfoSeiMessages, accessUnit, pcSlice->getTLayer(), pcSlice->getSPS(), duData);
1937 xWriteDuSEIMessages(duInfoSeiMessages, accessUnit, pcSlice->getTLayer(), pcSlice->getSPS(), duData);
1949 if (m_pcCfg->getEfficientFieldIRAPEnabled())
1953 #if REDUCED_ENCODER_MEMORY
1964 delete pcBitstreamRedirect;
1966 assert ( (m_iNumPicCoded == iNumPicRcvd) );
1969 #if JVET_F0064_MSSSIM
1979 const Int rateMultiplier=(isField?2:1);
1984 const ChromaFormat chFmt = m_pcCfg->getChromaFormatIdc();
1986 #if JVET_F0064_MSSSIM
1988 printf(
"\n\nSUMMARY --------------------------------------------------------\n" );
1991 printf(
"\n\nI Slices--------------------------------------------------------\n" );
1994 printf(
"\n\nP Slices--------------------------------------------------------\n" );
1997 printf(
"\n\nB Slices--------------------------------------------------------\n" );
2001 printf(
"\n\nSUMMARY --------------------------------------------------------\n" );
2004 printf(
"\n\nI Slices--------------------------------------------------------\n" );
2007 printf(
"\n\nP Slices--------------------------------------------------------\n" );
2010 printf(
"\n\nB Slices--------------------------------------------------------\n" );
2014 if (!m_pcCfg->getSummaryOutFilename().empty())
2019 if (!m_pcCfg->getSummaryPicFilenameBase().empty())
2033 printf(
"\n\nSUMMARY INTERLACED ---------------------------------------------\n" );
2034 #if JVET_F0064_MSSSIM
2040 if (!m_pcCfg->getSummaryOutFilename().empty())
2046 printf(
"\nRVM: %.3lf\n" , xCalculateRVM());
2051 Bool bCalcDist =
false;
2052 m_pcLoopFilter->setCfg(m_pcCfg->getLFCrossTileBoundaryFlag());
2053 m_pcLoopFilter->loopFilterPic( pcPic );
2068 assert( iNumPicRcvd > 0 );
2070 if ( ( isField && (iPOCLast == 0 || iPOCLast == 1) ) || (!isField && (iPOCLast == 0)) )
2076 m_iGopSize = m_pcCfg->getGOPSize();
2078 assert (m_iGopSize > 0);
2097 if (isField && pocCurr > 1 && m_iGopSize!=1)
2102 for ( i = 0; i < (iNumPicRcvd - iTimeOffset + 1); i++ )
2107 rpcPicYuvRecOut = *(iterPicYuvRec);
2111 while (iterPic != rcListPic.end())
2113 rpcPic = *(iterPic);
2115 if (rpcPic->
getPOC() == pocCurr)
2122 assert (rpcPic !=
NULL);
2123 assert (rpcPic->
getPOC() == pocCurr);
2143 for(
Int y = 0; y < iHeight; y++ )
2145 for(
Int x = 0; x < iWidth; x++ )
2148 uiTotalDiff +=
UInt64((iTemp*iTemp) >> uiShift);
2157 #if JVET_F0064_MSSSIM
2158 Void TEncGOP::xCalculateAddPSNRs(
const Bool isField,
const Bool isFieldTopFieldFirst,
const Int iGOPid,
TComPic* pcPic,
const AccessUnit&accessUnit,
TComList<TComPic*> &rcListPic,
const Double dEncTime,
const InputColourSpaceConversion snr_conversion,
const Bool printFrameMSE,
const Bool printMSSSIM,
Double* PSNR_Y )
2160 xCalculateAddPSNR( pcPic, pcPic->
getPicYuvRec(), accessUnit, dEncTime, snr_conversion, printFrameMSE, printMSSSIM, PSNR_Y );
2164 xCalculateAddPSNR( pcPic, pcPic->
getPicYuvRec(), accessUnit, dEncTime, snr_conversion, printFrameMSE, PSNR_Y );
2170 Bool bothFieldsAreEncoded =
false;
2171 Int correspondingFieldPOC = pcPic->
getPOC();
2172 Int currentPicGOPPoc = m_pcCfg->getGOPEntry(iGOPid).m_POC;
2178 bothFieldsAreEncoded =
false;
2180 else if(pcPic->
getPOC() == 1)
2183 correspondingFieldPOC = 0;
2184 bothFieldsAreEncoded =
true;
2188 if(pcPic->
getPOC()%2 == 1)
2190 correspondingFieldPOC -= 1;
2191 currentPicGOPPoc -= 1;
2195 correspondingFieldPOC += 1;
2196 currentPicGOPPoc += 1;
2198 for(
Int i = 0; i < m_iGopSize; i ++)
2200 if(m_pcCfg->getGOPEntry(i).m_POC == currentPicGOPPoc)
2202 bothFieldsAreEncoded = m_pcCfg->getGOPEntry(i).m_isEncoded;
2208 if(bothFieldsAreEncoded)
2212 while ((*iterPic)->getPOC() != correspondingFieldPOC)
2216 TComPic* correspondingFieldPic = *(iterPic);
2218 if( (pcPic->
isTopField() && isFieldTopFieldFirst) || (!pcPic->
isTopField() && !isFieldTopFieldFirst))
2220 #if JVET_F0064_MSSSIM
2221 xCalculateInterlacedAddPSNR(pcPic, correspondingFieldPic, pcPic->
getPicYuvRec(), correspondingFieldPic->
getPicYuvRec(), snr_conversion, printFrameMSE, printMSSSIM, PSNR_Y );
2223 xCalculateInterlacedAddPSNR(pcPic, correspondingFieldPic, pcPic->
getPicYuvRec(), correspondingFieldPic->
getPicYuvRec(), snr_conversion, printFrameMSE, PSNR_Y );
2228 #if JVET_F0064_MSSSIM
2229 xCalculateInterlacedAddPSNR(correspondingFieldPic, pcPic, correspondingFieldPic->
getPicYuvRec(), pcPic->
getPicYuvRec(), snr_conversion, printFrameMSE, printMSSSIM, PSNR_Y );
2231 xCalculateInterlacedAddPSNR(correspondingFieldPic, pcPic, correspondingFieldPic->
getPicYuvRec(), pcPic->
getPicYuvRec(), snr_conversion, printFrameMSE, PSNR_Y );
2238 #if JVET_F0064_MSSSIM
2273 Int iSize = iWidth*iHeight;
2276 for(
Int y = 0; y < iHeight; y++ )
2278 for(
Int x = 0; x < iWidth; x++ )
2281 uiSSDtemp += iDiff * iDiff;
2287 const Double fRefValue = (
Double) maxval * maxval * iSize;
2288 dPSNR[ch] = ( uiSSDtemp ? 10.0 * log10( fRefValue / (
Double)uiSSDtemp ) : 999.99 );
2289 MSEyuvframe[ch] = (
Double)uiSSDtemp/(iSize);
2291 #if EXTENSION_360_VIDEO
2292 m_ext360.calculatePSNRs(pcPic);
2295 #if JVET_F0064_MSSSIM
2312 MSSSIM[ch] = xCalculateMSSSIM (pOrg, orgStride, pRec, recStride, width, height, bitDepth);
2320 UInt numRBSPBytes = 0;
2321 for (AccessUnit::const_iterator it = accessUnit.begin(); it != accessUnit.end(); it++)
2323 UInt numRBSPBytes_nal =
UInt((*it)->m_nalUnitData.str().size());
2324 if (m_pcCfg->getSummaryVerboseness() > 0)
2326 printf(
"*** %6s numBytesInNALunit: %u\n",
nalUnitTypeToString((*it)->m_nalUnitType), numRBSPBytes_nal);
2330 numRBSPBytes += numRBSPBytes_nal;
2343 UInt uibits = numRBSPBytes * 8;
2344 m_vRVM_RP.push_back( uibits );
2347 #if JVET_F0064_MSSSIM
2352 #if EXTENSION_360_VIDEO
2359 #if JVET_F0064_MSSSIM
2364 #if EXTENSION_360_VIDEO
2371 #if JVET_F0064_MSSSIM
2376 #if EXTENSION_360_VIDEO
2383 #if JVET_F0064_MSSSIM
2388 #if EXTENSION_360_VIDEO
2400 #if ADAPTIVE_QP_SELECTION
2401 printf(
"POC %4d TId: %1d ( %c-SLICE, nQP %d QP %d ) %10d bits",
2409 printf(
"POC %4d TId: %1d ( %c-SLICE, QP %d ) %10d bits",
2418 #if JVET_F0064_MSSSIM
2421 printf(
" [MS-SSIM Y %1.6lf U %1.6lf V %1.6lf]", MSSSIM[COMPONENT_Y], MSSSIM[COMPONENT_Cb], MSSSIM[COMPONENT_Cr] );
2426 printf(
" [Y MSE %6.4lf U MSE %6.4lf V MSE %6.4lf]", MSEyuvframe[COMPONENT_Y], MSEyuvframe[COMPONENT_Cb], MSEyuvframe[COMPONENT_Cr] );
2428 #if EXTENSION_360_VIDEO
2429 m_ext360.printPerPOCInfo();
2431 printf(
" [ET %5.0f ]", dEncTime );
2435 for (
Int iRefList = 0; iRefList < 2; iRefList++)
2437 printf(
" [L%d ", iRefList);
2448 #if JVET_F0064_MSSSIM
2451 const Int MAX_MSSSIM_SCALE = 5;
2452 const Int WEIGHTING_MID_TAP = 5;
2453 const Int WEIGHTING_SIZE = WEIGHTING_MID_TAP*2+1;
2458 if (width < 22 || height < 22)
2462 else if (width < 44 || height < 44)
2466 else if (width < 88 || height < 88)
2470 else if (width < 176 || height < 176)
2479 assert(maxScale>0 && maxScale<=MAX_MSSSIM_SCALE);
2482 Double weights[WEIGHTING_SIZE][WEIGHTING_SIZE];
2485 for(
Int y=0; y<WEIGHTING_SIZE; y++)
2487 for(
Int x=0; x<WEIGHTING_SIZE; x++)
2489 weights[y][x]=exp(-((y-WEIGHTING_MID_TAP)*(y-WEIGHTING_MID_TAP)+(x-WEIGHTING_MID_TAP)*(x-WEIGHTING_MID_TAP))/(WEIGHTING_MID_TAP-0.5));
2490 coeffSum +=weights[y][x];
2494 for(
Int y=0; y<WEIGHTING_SIZE; y++)
2496 for(
Int x=0; x<WEIGHTING_SIZE; x++)
2498 weights[y][x] /=coeffSum;
2504 const Double exponentWeights[MAX_MSSSIM_SCALE][MAX_MSSSIM_SCALE] = {{1.0, 0, 0, 0, 0 },
2505 {0.1356, 0.8644, 0, 0, 0 },
2506 {0.0711, 0.4530, 0.4760, 0, 0 },
2507 {0.0517, 0.3295, 0.3462, 0.2726, 0 },
2508 {0.0448, 0.2856, 0.3001, 0.2363, 0.1333}};
2511 std::vector<Double> original[MAX_MSSSIM_SCALE];
2512 std::vector<Double> recon[MAX_MSSSIM_SCALE];
2514 for(
UInt scale=0; scale<maxScale; scale++)
2516 const Int scaledHeight = height >> scale;
2517 const Int scaledWidth = width >> scale;
2518 original[scale].resize(scaledHeight*scaledWidth,
Double(0));
2519 recon[scale].resize(scaledHeight*scaledWidth,
Double(0));
2523 for(
Int y=0; y<height; y++)
2525 for(
Int x=0; x<width; x++)
2527 original[0][y*width+x] = pOrg[y*orgStride+x];
2528 recon[0][ y*width+x] = pRec[y*recStride+x];
2533 for(
UInt scale=1; scale<maxScale; scale++)
2535 const Int scaledHeight = height >> scale;
2536 const Int scaledWidth = width >> scale;
2537 for(
Int y=0; y<scaledHeight; y++)
2539 for(
Int x=0; x<scaledWidth; x++)
2541 original[scale][y*scaledWidth+x]= (original[scale-1][ 2*y *(2*scaledWidth)+2*x ] +
2542 original[scale-1][ 2*y *(2*scaledWidth)+2*x+1] +
2543 original[scale-1][(2*y+1)*(2*scaledWidth)+2*x ] +
2544 original[scale-1][(2*y+1)*(2*scaledWidth)+2*x+1]) / 4.0;
2545 recon[scale][y*scaledWidth+x]= ( recon[scale-1][ 2*y *(2*scaledWidth)+2*x ] +
2546 recon[scale-1][ 2*y *(2*scaledWidth)+2*x+1] +
2547 recon[scale-1][(2*y+1)*(2*scaledWidth)+2*x ] +
2548 recon[scale-1][(2*y+1)*(2*scaledWidth)+2*x+1]) / 4.0;
2554 const UInt maxValue = (1<<bitDepth)-1;
2555 const Double c1 = (0.01*maxValue)*(0.01*maxValue);
2556 const Double c2 = (0.03*maxValue)*(0.03*maxValue);
2558 Double finalMSSSIM = 1.0;
2560 for(
UInt scale=0; scale<maxScale; scale++)
2562 const Int scaledHeight = height >> scale;
2563 const Int scaledWidth = width >> scale;
2564 const Int blocksPerRow = scaledWidth-WEIGHTING_SIZE+1;
2565 const Int blocksPerColumn = scaledHeight-WEIGHTING_SIZE+1;
2566 const Int totalBlocks = blocksPerRow*blocksPerColumn;
2570 for(
Int blockIndexY=0; blockIndexY<blocksPerColumn; blockIndexY++)
2572 for(
Int blockIndexX=0; blockIndexX<blocksPerRow; blockIndexX++)
2578 Double muOrigMultRec =0.0;
2580 for(
Int y=0; y<WEIGHTING_SIZE; y++)
2582 for(
Int x=0;x<WEIGHTING_SIZE; x++)
2584 const Double gaussianWeight=weights[y][x];
2585 const Int sampleOffset=(blockIndexY+y)*scaledWidth+(blockIndexX+x);
2586 const Double orgPel=original[scale][sampleOffset];
2587 const Double recPel= recon[scale][sampleOffset];
2589 muOrg +=orgPel* gaussianWeight;
2590 muRec +=recPel* gaussianWeight;
2591 muOrigSqr +=orgPel*orgPel*gaussianWeight;
2592 muRecSqr +=recPel*recPel*gaussianWeight;
2593 muOrigMultRec+=orgPel*recPel*gaussianWeight;
2597 const Double sigmaSqrOrig = muOrigSqr -(muOrg*muOrg);
2598 const Double sigmaSqrRec = muRecSqr -(muRec*muRec);
2599 const Double sigmaOrigRec = muOrigMultRec-(muOrg*muRec);
2601 Double blockSSIMVal = ((2.0*sigmaOrigRec + c2)/(sigmaSqrOrig+sigmaSqrRec + c2));
2602 if(scale == maxScale-1)
2604 blockSSIMVal*=(2.0*muOrg*muRec + c1)/(muOrg*muOrg+muRec*muRec + c1);
2607 meanSSIM += blockSSIMVal;
2611 meanSSIM /=totalBlocks;
2613 finalMSSSIM *= pow(meanSSIM, exponentWeights[maxScale-1][scale]);
2631 TComPic *apcPicOrgFields[2]={pcPicOrgFirstField, pcPicOrgSecondField};
2632 TComPicYuv *apcPicRecFields[2]={pcPicRecFirstField, pcPicRecSecondField};
2642 for(
UInt fieldNum=0; fieldNum<2; fieldNum++)
2644 TComPicYuv &reconField=*(apcPicRecFields[fieldNum]);
2647 apcPicRecFields[fieldNum]=cscd+fieldNum;
2654 assert(apcPicRecFields[0]->getChromaFormat()==apcPicRecFields[1]->getChromaFormat());
2657 for(
Int chan=0; chan<numValidComponents; chan++)
2660 assert(apcPicRecFields[0]->getWidth(ch)==apcPicRecFields[1]->getWidth(ch));
2661 assert(apcPicRecFields[0]->getHeight(ch)==apcPicRecFields[1]->getHeight(ch));
2667 Int iSize = iWidth*iHeight;
2669 for(
UInt fieldNum=0; fieldNum<2; fieldNum++)
2671 TComPic *pcPic=apcPicOrgFields[fieldNum];
2672 TComPicYuv *pcPicD=apcPicRecFields[fieldNum];
2679 for(
Int y = 0; y < iHeight; y++ )
2681 for(
Int x = 0; x < iWidth; x++ )
2684 uiSSDtemp += iDiff * iDiff;
2691 const Double fRefValue = (
Double) maxval * maxval * iSize*2;
2692 dPSNR[ch] = ( uiSSDtemp ? 10.0 * log10( fRefValue / (
Double)uiSSDtemp ) : 999.99 );
2693 MSEyuvframe[ch] = (
Double)uiSSDtemp/(iSize*2);
2696 #if JVET_F0064_MSSSIM
2701 for(
Int chan=0; chan<numValidComponents; chan++)
2704 assert(apcPicRecFields[0]->getWidth(ch) ==apcPicRecFields[1]->getWidth(ch) );
2705 assert(apcPicRecFields[0]->getHeight(ch)==apcPicRecFields[1]->getHeight(ch));
2707 Double sumOverFieldsMSSSIM = 0.0;
2711 for(
UInt fieldNum=0; fieldNum<2; fieldNum++)
2713 TComPic *pcPic = apcPicOrgFields[fieldNum];
2714 TComPicYuv *pcPicD = apcPicRecFields[fieldNum];
2722 sumOverFieldsMSSSIM += xCalculateMSSSIM (pOrg, orgStride, pRec, recStride, width, height, bitDepth);
2725 MSSSIM[ch] = sumOverFieldsMSSSIM/2;
2733 #if JVET_F0064_MSSSIM
2742 #if JVET_F0064_MSSSIM
2753 for(
UInt fieldNum=0; fieldNum<2; fieldNum++)
2773 if(m_pcCfg->getEfficientFieldIRAPEnabled() && isField && pocCurr == 1)
2779 if(m_pcCfg->getDecodingRefreshType() != 3 && (pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0)
2781 if (m_pcCfg->getDecodingRefreshType() == 1)
2785 else if (m_pcCfg->getDecodingRefreshType() == 2)
2792 if(pocCurr<m_pocCRA)
2804 if (pocCurr < lastIDR)
2816 if( m_pcCfg->getGOPSize() == 1 && m_pcCfg->getIntraPeriod() != 1 && m_pcCfg->getFramesToBeEncoded() >
RVM_VCEGAM10_M * 2 )
2819 std::vector<Double> vRL , vB;
2820 size_t N = m_vRVM_RP.size();
2825 Double dRavg = 0 , dBavg = 0;
2830 for(
Int j = i - RVM_VCEGAM10_M ; j <= i + RVM_VCEGAM10_M - 1 ; j++ )
2832 vRL[i] += m_vRVM_RP[j];
2835 vB[i] = vB[i-1] + m_vRVM_RP[i] - vRL[i];
2836 dRavg += m_vRVM_RP[i];
2844 for( i = RVM_VCEGAM10_M + 1 ; i < N - RVM_VCEGAM10_M + 1 ; i++ )
2846 Double tmp = vB[i] - dBavg;
2847 dSigamB += tmp * tmp;
2849 dSigamB = sqrt( dSigamB / ( N - 2 * RVM_VCEGAM10_M ) );
2851 Double f = sqrt( 12.0 * ( RVM_VCEGAM10_M - 1 ) / ( RVM_VCEGAM10_M + 1 ) );
2853 dRVM = dSigamB / dRavg * f;
2875 m_pcEntropyCoder->setBitstream(&rNalu.
m_Bitstream);
2877 codedSliceData->
clear();
2897 ::memset(longtermPicsPoc, 0,
sizeof(longtermPicsPoc));
2898 ::memset(longtermPicsLSB, 0,
sizeof(longtermPicsLSB));
2899 ::memset(longtermPicsMSB, 0,
sizeof(longtermPicsMSB));
2900 ::memset(indices , 0,
sizeof(indices));
2901 ::memset(mSBPresentFlag , 0,
sizeof(mSBPresentFlag));
2904 Int offset = rps->getNumberOfNegativePictures() + rps->getNumberOfPositivePictures();
2907 for(i = rps->getNumberOfPictures() - 1; i >= offset; i--, ctr++)
2909 longtermPicsPoc[ctr] = rps->getPOC(i);
2910 longtermPicsLSB[ctr] =
getLSB(longtermPicsPoc[ctr], maxPicOrderCntLSB);
2912 longtermPicsMSB[ctr] = longtermPicsPoc[ctr] - longtermPicsLSB[ctr];
2914 Int numLongPics = rps->getNumberOfLongtermPictures();
2915 assert(ctr == numLongPics);
2918 for(i = 0; i < numLongPics; i++)
2920 for(
Int j = 0; j < numLongPics - 1; j++)
2922 if(longtermPicsMSB[j] < longtermPicsMSB[j+1])
2924 std::swap(longtermPicsPoc[j], longtermPicsPoc[j+1]);
2925 std::swap(longtermPicsLSB[j], longtermPicsLSB[j+1]);
2926 std::swap(longtermPicsMSB[j], longtermPicsMSB[j+1]);
2927 std::swap(indices[j] , indices[j+1] );
2932 for(i = 0; i < numLongPics; i++)
2938 while ( iterPic != rcListPic.end() )
2941 if( (
getLSB(pcPic->
getPOC(), maxPicOrderCntLSB) == longtermPicsLSB[i]) &&
2943 (pcPic->
getPOC() != longtermPicsPoc[i]) )
2945 mSBPresentFlag[i] =
true;
2954 for(i = 0; i < numLongPics; i++)
2956 tempArray[i] = rps->getUsed(indices[i]);
2960 Int currMSB = 0, currLSB = 0;
2962 currLSB =
getLSB(pcSlice->
getPOC(), maxPicOrderCntLSB);
2963 currMSB = pcSlice->
getPOC() - currLSB;
2965 for(i = rps->getNumberOfPictures() - 1; i >= offset; i--, ctr++)
2967 rps->setPOC (i, longtermPicsPoc[ctr]);
2968 rps->setDeltaPOC (i, - pcSlice->
getPOC() + longtermPicsPoc[ctr]);
2969 rps->setUsed (i, tempArray[ctr]);
2970 rps->setPocLSBLT (i, longtermPicsLSB[ctr]);
2971 rps->setDeltaPocMSBCycleLT (i, (currMSB - (longtermPicsPoc[ctr] - longtermPicsLSB[ctr])) / maxPicOrderCntLSB);
2972 rps->setDeltaPocMSBPresentFlag(i, mSBPresentFlag[ctr]);
2974 assert(rps->getDeltaPocMSBCycleLT(i) >= 0);
2976 for(i = rps->getNumberOfPictures() - 1, ctr = 1; i >= offset; i--, ctr++)
2978 for(
Int j = rps->getNumberOfPictures() - 1 - ctr; j >= offset; j--)
2982 assert( rps->getPOC(i) != rps->getPOC(j) );
2994 UInt maxTBsize = (1<<log2maxTB);
2995 const UInt minBlockArtSize = 8;
2998 const UInt noCol = (picWidth>>log2maxTB);
2999 const UInt noRows = (picHeight>>log2maxTB);
3002 std::vector<UInt64> colSAD(noCol,
UInt64(0));
3003 std::vector<UInt64> rowSAD(noRows,
UInt64(0));
3006 Pel p0, p1, p2, q0, q1, q2;
3010 Int bitdepthScale = 1 << (bitDepthLuma-8);
3012 const Int thr2 = (beta>>2);
3013 const Int thr1 = 2*bitdepthScale;
3016 if (maxTBsize > minBlockArtSize)
3019 for(
Int c = maxTBsize; c < picWidth; c += maxTBsize)
3021 for(
Int r = 0; r < picHeight; r++)
3029 a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1);
3030 if ( thr1 < a && a < thr2)
3032 colSAD[colIdx] += abs(p0 - q0);
3041 for(
Int r = maxTBsize; r < picHeight; r += maxTBsize)
3043 for(
Int c = 0; c < picWidth; c++)
3045 p2 = Rec[c + (r-3)*stride];
3046 p1 = Rec[c + (r-2)*stride];
3047 p0 = Rec[c + (r-1)*stride];
3048 q0 = Rec[c + r*stride];
3049 q1 = Rec[c + (r+1)*stride];
3050 q2 = Rec[c + (r+2)*stride];
3051 a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1);
3052 if (thr1 < a && a < thr2)
3054 rowSAD[rowIdx] += abs(p0 - q0);
3063 for(
Int c = 0; c < noCol-1; c++)
3065 colSADsum += colSAD[c];
3067 for(
Int r = 0; r < noRows-1; r++)
3069 rowSADsum += rowSAD[r];
3074 colSADsum /= (noCol-1);
3075 colSADsum /= picHeight;
3076 rowSADsum /= (noRows-1);
3077 rowSADsum /= picWidth;
3079 UInt64 avgSAD = ((colSADsum + rowSADsum)>>1);
3080 avgSAD >>= (bitDepthLuma-8);
3082 if ( avgSAD > 2048 )
3086 for (
Int i=0; i<uiNumSlices; i++)
3096 for (
Int i=0; i<uiNumSlices; i++)
3110 DBFLT_PARAM_AVAILABLE = 0,
3112 DBFLT_BETA_OFFSETD2,
3116 const Int MAX_BETA_OFFSET = 3;
3117 const Int MIN_BETA_OFFSET = -3;
3118 const Int MAX_TC_OFFSET = 3;
3119 const Int MIN_TC_OFFSET = -3;
3127 if(!m_pcDeblockingTempPicYuv)
3131 memset(m_DBParam, 0,
sizeof(m_DBParam));
3135 pcPicYuvRec->
copyToPic(m_pcDeblockingTempPicYuv);
3137 const Bool bNoFiltering = m_DBParam[currQualityLayer][DBFLT_PARAM_AVAILABLE] && m_DBParam[currQualityLayer][DBFLT_DISABLE_FLAG]==
false ;
3138 const Int maxBetaOffsetDiv2 = bNoFiltering?
Clip3(MIN_BETA_OFFSET, MAX_BETA_OFFSET, m_DBParam[currQualityLayer][DBFLT_BETA_OFFSETD2]+1) : MAX_BETA_OFFSET;
3139 const Int minBetaOffsetDiv2 = bNoFiltering?
Clip3(MIN_BETA_OFFSET, MAX_BETA_OFFSET, m_DBParam[currQualityLayer][DBFLT_BETA_OFFSETD2]-1) : MIN_BETA_OFFSET;
3140 const Int maxTcOffsetDiv2 = bNoFiltering?
Clip3(MIN_TC_OFFSET, MAX_TC_OFFSET, m_DBParam[currQualityLayer][DBFLT_TC_OFFSETD2]+2) : MAX_TC_OFFSET;
3141 const Int minTcOffsetDiv2 = bNoFiltering?
Clip3(MIN_TC_OFFSET, MAX_TC_OFFSET, m_DBParam[currQualityLayer][DBFLT_TC_OFFSETD2]-2) : MIN_TC_OFFSET;
3143 UInt64 distBetaPrevious = std::numeric_limits<UInt64>::max();
3144 UInt64 distMin = std::numeric_limits<UInt64>::max();
3145 Bool bDBFilterDisabledBest =
true;
3146 Int betaOffsetDiv2Best = 0;
3147 Int tcOffsetDiv2Best = 0;
3149 for(
Int betaOffsetDiv2=maxBetaOffsetDiv2; betaOffsetDiv2>=minBetaOffsetDiv2; betaOffsetDiv2--)
3151 UInt64 distTcMin = std::numeric_limits<UInt64>::max();
3152 for(
Int tcOffsetDiv2=maxTcOffsetDiv2; tcOffsetDiv2 >= minTcOffsetDiv2; tcOffsetDiv2--)
3154 for (
Int i=0; i<numSlices; i++)
3161 m_pcDeblockingTempPicYuv->copyToPic(pcPicYuvRec);
3162 m_pcLoopFilter->loopFilterPic( pcPic );
3167 bDBFilterDisabledBest =
false;
3168 betaOffsetDiv2Best = betaOffsetDiv2;
3169 tcOffsetDiv2Best = tcOffsetDiv2;
3171 if(dist < distTcMin)
3175 else if(tcOffsetDiv2 <-2)
3180 if(betaOffsetDiv2<-1 && distTcMin >= distBetaPrevious)
3184 distBetaPrevious = distTcMin;
3188 m_DBParam[currQualityLayer][DBFLT_PARAM_AVAILABLE] = 1;
3189 m_DBParam[currQualityLayer][DBFLT_DISABLE_FLAG] = bDBFilterDisabledBest;
3190 m_DBParam[currQualityLayer][DBFLT_BETA_OFFSETD2] = betaOffsetDiv2Best;
3191 m_DBParam[currQualityLayer][DBFLT_TC_OFFSETD2] = tcOffsetDiv2Best;
3193 m_pcDeblockingTempPicYuv->copyToPic(pcPicYuvRec);
3195 if(bDBFilterDisabledBest)
3197 for (
Int i=0; i<numSlices; i++)
3205 for (
Int i=0; i<numSlices; i++)
3215 for (
Int i=0; i<numSlices; i++)
Void releaseEncoderSourceImageData()
Bool getNalHrdParametersPresentFlag() const
Int getNumTileRowsMinus1() const
static const Int MAX_NUM_REF_PICS
max. number of pictures used for reference
Void xWriteLeadingSEIOrdered(SEIMessages &seiMessages, SEIMessages &duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, Bool testWrite)
Bool isStepwiseTemporalLayerSwitchingPointCandidate(TComList< TComPic * > &rcListPic)
Void setNoOutputPriorPicsFlag(Bool val)
Int m_duSptCpbRemovalDelay
Void clearSubstreamSizes()
Bool getVclHrdParametersPresentFlag() const
Void setDeblockingFilterTcOffsetDiv2(Int i)
TComSEIMasteringDisplay values
Int xWriteSPS(AccessUnit &accessUnit, const TComSPS *sps)
static UInt calculateCollocatedFromL0Flag(const TComSlice *pSlice)
SliceType getSliceType() const
Void setDependentSliceSegmentFlag(Bool val)
Void xAttachSliceDataToNalUnit(OutputNALUnit &rNalu, TComOutputBitstream *pcBitstreamRedirect)
Void setFrmRate(Double dFrameRate)
Void setColFromL0Flag(Bool colFromL0)
Void xInitGOP(Int iPOCLast, Int iNumPicRcvd, Bool isField)
NalUnitType getNalUnitType(Int pocCurr, Int lastIdr, Bool isField)
encoder analyzer class (header)
Bool getTemporalLayerNonReferenceFlag()
TEncRateCtrl * getRateCtrl()
Int getNumTileColumnsMinus1() const
GOP encoder class (header)
picture class (symbol + YUV buffers)
const TChar * nalUnitTypeToString(NalUnitType type)
Int getUsed(Int bufferNum) const
Void writeByteAlignment()
Int getStride(const ComponentID id) const
Void xWriteTrailingSEIMessages(SEIMessages &seiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps)
void copyTo(SEIBufferingPeriod &target)
Void preLoopFilterPicAll(TComPic *pcPic, UInt64 &ruiDist)
UInt getTimeScale() const
void copyTo(SEIPictureTiming &target)
Void setDeblockingFilterBetaOffsetDiv2(Int i)
Void deleteSEIs(SEIMessages &seiList)
delete list of SEI messages (freeing the referenced objects)
static Void ColourSpaceConvert(const TComPicYuv &src, TComPicYuv &dest, const InputColourSpaceConversion conversion, Bool bIsForwards)
NalUnitType getAssociatedIRAPType() const
SEIMessages getSeisByType(SEIMessages &seiList, SEI::PayloadType seiType)
output a selection of SEI messages by payload type. Ownership stays in original message list...
Void createWithoutCUInfo(const Int picWidth, const Int picHeight, const ChromaFormat chromaFormatIDC, const Bool bUseMargin=false, const UInt maxCUWidth=0, const UInt maxCUHeight=0)
used for margin only
Void setEnableTMVPFlag(Bool b)
Int getHeight(const ComponentID id) const
Int xWriteVPS(AccessUnit &accessUnit, const TComVPS *vps)
UInt getBitsForPOC() const
TComSlice * getSlice(Int i)
Void copySliceInfo(TComSlice *pcSliceSrc)
Void codeAUD(TComBitIf &bs, const Int pictureType)
Void setSaoEnabledFlag(ChannelType chType, Bool s)
Bool isReferenced() const
Void setNalUnitType(NalUnitType e)
Void xWriteAccessUnitDelimiter(AccessUnit &accessUnit, TComSlice *slice)
Void xClearSEIs(SEIMessages &seiMessages, Bool deleteMessages)
const TComRPSList * getRPSList() const
static Void printHash(const HashType hashType, const std::string &digestStr)
Void printOut(TChar cDelim, const ChromaFormat chFmt, const Bool printMSEBasedSNR, const Bool printSequenceMSE, const Bool printMSSSIM, const BitDepths &bitDepths)
UInt getMaxCUHeight() const
Void xCreatePerPictureSEIMessages(Int picInGOP, SEIMessages &seiMessages, SEIMessages &nestedSeiMessages, TComSlice *slice)
std::vector< UInt > m_numNalusInDuMinus1
Bool getNoRaslOutputFlag() const
Void xCalculateAddPSNRs(const Bool isField, const Bool isFieldTopFieldFirst, const Int iGOPid, TComPic *pcPic, const AccessUnit &accessUnit, TComList< TComPic * > &rcListPic, Double dEncTime, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE, const Bool printMSSSIM, Double *PSNR_Y)
TComRefPicListModification * getRefPicListModification()
Bool isTemporalLayerSwitchingPoint(TComList< TComPic * > &rcListPic)
Bool getPPSDeblockingFilterDisabledFlag() const
get offset for deblocking filter disabled
static Int getBeta(Int qp)
Void setSliceCurStartCtuTsAddr(UInt ctuTsAddr)
Void xCreatePictureTimingSEI(Int IRAPGOPid, SEIMessages &seiMessages, SEIMessages &nestedSeiMessages, SEIMessages &duInfoSeiMessages, TComSlice *slice, Bool isField, std::deque< DUData > &duData)
Reference Picture Lists class.
Void setAssociatedIRAPPOC(Int iAssociatedIRAPPOC)
TEncEntropy * getEntropyCoder()
Void setRPS(const TComReferencePictureSet *pcRPS)
Void addResult(Double psnr[MAX_NUM_COMPONENT], Double bits, const Double MSEyuvframe[MAX_NUM_COMPONENT], const Double MSSSIM[MAX_NUM_COMPONENT])
Int recon[MAX_NUM_CHANNEL_TYPE]
the bit depth as indicated in the SPS
Int getNumRefIdx(RefPicList e) const
Int adjustGOPid(const Int gopID)
Void setLastIDR(Int iIDRPOC)
Void setRefPicListModificationFlagL1(Bool flag)
UInt getMinCUWidth() const
Void setEncCABACTableIdx(SliceType idx)
SEIMessages extractSeisByType(SEIMessages &seiList, SEI::PayloadType seiType)
remove a selection of SEI messages by payload type from the original list and return them in a new li...
TComVUI * getVuiParameters()
Void setSliceBits(UInt uiVal)
Void setLFCrossSliceBoundaryFlag(Bool val)
static const Int MAX_ENCODER_DEBLOCKING_QUALITY_LAYERS
TComPicYuv * getPicYuvRec()
Void setList1IdxToList0Idx()
Void setRefPicListModificationFlagL0(Bool flag)
Int m_POC[MAX_NUM_REF_PICS]
Int m_picSptDpbOutputDuDelay
UInt getMaxTotalCUDepth() const
static Void cabac_zero_word_padding(TComSlice *const pcSlice, TComPic *const pcPic, const std::size_t binCountsInNalUnits, const std::size_t numBytesInVclNalUnits, std::ostringstream &nalUnitData, const Bool cabacZeroWordPaddingEnabled)
Void xGetBuffer(TComList< TComPic * > &rcListPic, TComList< TComPicYuv * > &rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic *&rpcPic, TComPicYuv *&rpcPicYuvRecOut, Int pocCurr, Bool isField)
Bool getLoopFilterAcrossSlicesEnabledFlag() const
TEncAnalyze m_gcAnalyzeAll_in
static const Int RVM_VCEGAM10_M
Void xUpdateDuInfoSEI(SEIMessages &duInfoSeiMessages, SEIPictureTiming *pictureTimingSEI)
Int getWidth(const ComponentID id) const
Void setSliceType(SliceType e)
Void setNoRaslOutputFlag(Bool val)
TEncSbac * getSbacCoder()
TComList< TComPic * > * getListPic()
Int Intermediate_Int
used as intermediate value in calculations
Int getStride(const ComponentID id) const
Void xUpdateTimingSEI(SEIPictureTiming *pictureTimingSEI, std::deque< DUData > &duData, const TComSPS *sps)
TComLoopFilter * getLoopFilter()
Bool getTemporalIdNestingFlag() const
Int getQpBDOffset(ChannelType type) const
UInt getComponentScaleX(const ComponentID id) const
Int xWritePPS(AccessUnit &accessUnit, const TComPPS *pps)
EfficientFieldIRAPMapping()
const TComReferencePictureSet * getRPS()
UInt getSubstreamForCtuAddr(const UInt ctuAddr, const Bool bAddressInRaster, TComSlice *pcSlice)
Void xCalculateInterlacedAddPSNR(TComPic *pcPicOrgFirstField, TComPic *pcPicOrgSecondField, TComPicYuv *pcPicRecFirstField, TComPicYuv *pcPicRecSecondField, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE, const Bool printMSSSIM, Double *PSNR_Y)
Bool getSubPicCpbParamsPresentFlag() const
TComReferencePictureSet * getReferencePictureSet(Int referencePictureSetNum)
#define JVET_F0064_MSSSIM
Calculate MS-SSIM scores.
Int getAssociatedIRAPPOC() const
Void prepareForReconstruction()
UInt getMinCUHeight() const
Void decodingRefreshMarking(Int &pocCRA, Bool &bRefreshPending, TComList< TComPic * > &rcListPic, const bool bEfficientFieldIRAPEnabled)
Void copyToPic(TComPicYuv *pcPicYuvDst) const
UInt getPicHeightInLumaSamples() const
Void setAssociatedIRAPType(NalUnitType associatedIRAPType)
Double xCalculateMSSSIM(const Pel *pOrg, const Int orgStride, const Pel *pRec, const Int recStride, const Int width, const Int height, const UInt bitDepth)
UInt getSliceBits() const
UInt getNumberOfSubstreamSizes()
Int getDeltaPOC(Int bufferNum) const
Void releaseReconstructionIntermediateData()
Void setRefPicList(TComList< TComPic * > &rcListPic, Bool checkNumPocTotalCurr=false)
T Clip3(const T minVal, const T maxVal, const T a)
general min/max clip
UInt m_numDecodingUnitsMinus1
TEncAnalyze m_gcAnalyzeAll
Int getRefPOC(RefPicList e, Int iRefIdx) const
TComPicYuv * getPicYuvOrg()
Void xCreateScalableNestingSEI(SEIMessages &seiMessages, SEIMessages &nestedSeiMessages)
Int getBitDepth(ChannelType type) const
Void setDeblockingFilterOverrideFlag(Bool b)
Int getComponentScaleX(const ComponentID id) const
RefPicList
reference list index
Int restoreGOPid(const Int gopID)
UInt getNumberOfWrittenBits() const
Int getSliceQpBase() const
ChromaFormat
chroma formats (according to semantics of chroma_format_idc)
TEncCavlc * getCavlcCoder()
Void xWriteLeadingSEIMessages(SEIMessages &seiMessages, SEIMessages &duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, std::deque< DUData > &duData)
const BitDepths & getBitDepths() const
UInt getSliceSegmentCurStartCtuTsAddr() const
Void xWriteDuSEIMessages(SEIMessages &duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, std::deque< DUData > &duData)
TEncSlice * getSliceEncoder()
const TComPPS * getPPS() const
Int getDeblockingFilterBetaOffsetDiv2() const
get beta offset for deblocking filter
UInt getPicWidthInLumaSamples() const
Void setRPSidx(Int rpsIdx)
UInt getNumberValidComponents() const
Void arrangeLongtermPicturesInRPS(TComSlice *, TComList< TComPic * > &)
Void init(Bool isFieldCoding)
Void init(TEncTop *pcTEncTop)
const TComSPS & getSPS() const
Void printSummary(const ChromaFormat chFmt, const Bool printSequenceMSE, const BitDepths &bitDepths, const std::string &sFilename)
Bool getEntropyCodingSyncEnabledFlag() const
TimingInfo * getTimingInfo()
InputColourSpaceConversion
unsigned long long UInt64
UInt getCpbRemovalDelayLengthMinus1() const
const GOPEntry & getGOPEntry(Int i) const
Int getLSB(Int poc, Int maxLSB)
Void setReconMark(Bool b)
Void xWriteSEISeparately(NalUnitType naluType, SEIMessages &seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComSPS *sps)
Pel * getAddr(const ComponentID ch)
Bool m_duCommonCpbRemovalDelayFlag
Void checkColRefIdx(UInt curSliceIdx, TComPic *pic)
#define DISTORTION_PRECISION_ADJUSTMENT(x)
UInt getSliceSegmentCurEndCtuTsAddr() const
std::vector< UInt > m_duCpbRemovalDelayMinus1
std::list< SEI * > SEIMessages
Void create(const Int picWidth, const Int picHeight, const ChromaFormat chromaFormatIDC, const UInt maxCUWidth, const UInt maxCUHeight, const UInt maxCUDepth, const Bool bUseMargin)
if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image...
Void xCalculateAddPSNR(TComPic *pcPic, TComPicYuv *pcPicD, const AccessUnit &, Double dEncTime, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE, const Bool printMSSSIM, Double *PSNR_Y)
UInt getNumberOfCtusInFrame() const
Int getNumberOfPictures() const
Void setSliceSegmentCurStartCtuTsAddr(UInt ctuTsAddr)
UInt getQuadtreeTULog2MaxSize() const
UInt getFrameHeightInCtus() const
Void applyReferencePictureSet(TComList< TComPic * > &rcListPic, const TComReferencePictureSet *RPSList)
UInt getMaxTLayers() const
Int getComponentScaleY(const ComponentID id) const
const Double * getLambdas() const
Bool getRapPicFlag() const
Void initialize(const Bool isField, const Int gopSize, const Int POCLast, const Int numPicRcvd, const Int lastIDR, TEncGOP *pEncGop, TEncCfg *pCfg)
Void xUpdateDuData(AccessUnit &testAU, std::deque< DUData > &duData)
Int checkThatAllRefPicsAreAvailable(TComList< TComPic * > &rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess=0, Bool bUseRecoveryPoint=false)
Bool getLoopFilterAcrossTilesEnabledFlag() const
Int getNumberOfLongtermPictures() const
Void xCreateIRAPLeadingSEIMessages(SEIMessages &seiMessages, const TComSPS *sps, const TComPPS *pps)
UInt m_picDpbOutputDuDelay
Void setDeblockingFilterDisable(Bool b)
encoder configuration class
Void createExplicitReferencePictureSetFromReference(TComList< TComPic * > &rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess, Bool bUseRecoveryPoint, const Bool bEfficientFieldIRAPEnabled)
Int xWriteParameterSets(AccessUnit &accessUnit, TComSlice *slice, const Bool bSeqFirst)
Void applyDeblockingFilterMetric(TComPic *pcPic, UInt uiNumSlices)
Bool m_dpbOutputDuDelayPresentFlag
Reference Picture Set class.
NalUnitType getNalUnitType() const
Void setFinalized(Bool uiVal)
Void setNumRefIdx(RefPicList e, Int i)
TEncBinCABAC * getBinCABAC()
Void addSubstream(TComOutputBitstream *pcSubstream)
Int getDeblockingFilterTcOffsetDiv2() const
get tc offset for deblocking filter
Void setMvdL1ZeroFlag(Bool b)
Int m_referencePics[MAX_NUM_REF_PICS]
UInt64 xFindDistortionFrame(TComPicYuv *pcPic0, TComPicYuv *pcPic1, const BitDepths &bitDepths)
TComPic * getRefPic(RefPicList e, Int iRefIdx)
UInt getNumUnitsInTick() const
Void setBits(Double numBits)
Void applyDeblockingFilterParameterSelection(TComPic *pcPic, const UInt numSlices, const Int gopID)
TComOutputBitstream m_Bitstream
TEncSampleAdaptiveOffset * getSAO()
TComReferencePictureSet * getLocalRPS()
TComHRD * getHrdParameters()
Bool getVuiParametersPresentFlag() const
UInt getSliceCurEndCtuTsAddr() const
Int getNumReorderPics(UInt tlayer) const
Void xWriteSEI(NalUnitType naluType, SEIMessages &seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComSPS *sps)
Void setCurrSliceIdx(UInt i)
UInt getMaxCUWidth() const
Void compressGOP(Int iPOCLast, Int iNumPicRcvd, TComList< TComPic * > &rcListPic, TComList< TComPicYuv * > &rcListPicYuvRec, std::list< AccessUnit > &accessUnitsInGOP, Bool isField, Bool isTff, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE, const Bool printMSSSIM)
Void printOutSummary(UInt uiNumAllPicCoded, Bool isField, const Bool printMSEBasedSNR, const Bool printSequenceMSE, const Bool printMSSSIM, const BitDepths &bitDepths)
const TComSPS * getSPS() const
ChromaFormat getChromaFormat() const
UInt getTickDivisorMinus2() const