87 UChar combinedSubTUCBF = 0;
89 for (
UInt subTU = 0; subTU < 2; subTU++)
91 const UInt subTUAbsPartIdx = uiAbsPartIdx + (subTU * partIdxesPerSubTU);
93 subTUCBF[subTU] = pcCU->
getCbf(subTUAbsPartIdx, compID, uiTrDepth);
94 combinedSubTUCBF |= subTUCBF[subTU];
97 for (
UInt subTU = 0; subTU < 2; subTU++)
99 const UInt subTUAbsPartIdx = uiAbsPartIdx + (subTU * partIdxesPerSubTU);
100 const UChar compositeCBF = (subTUCBF[subTU] << 1) | combinedSubTUCBF;
102 pcCU->
setCbfPartRange((compositeCBF << uiTrDepth), compID, subTUAbsPartIdx, partIdxesPerSubTU);
108 : m_puhQTTempTrIdx(
NULL)
109 , m_pcQTTempTComYuv(
NULL)
113 , m_pcEntropyCoder (
NULL)
115 , m_bipredSearchRange (0)
117 , m_pppcRDSbacCoder (
NULL)
118 , m_pcRDGoOnSbacCoder (
NULL)
120 , m_isInitialized (false)
125 #if ADAPTIVE_QP_SELECTION
132 #if ADAPTIVE_QP_SELECTION
166 for (
UInt layer = 0; layer < uiNumLayersAllocated; layer++)
169 #if ADAPTIVE_QP_SELECTION
175 #if ADAPTIVE_QP_SELECTION
180 for(
UInt layer = 0; layer < uiNumLayersAllocated; layer++ )
193 #if ADAPTIVE_QP_SELECTION
219 Int bipredSearchRange,
221 const UInt maxCUWidth,
222 const UInt maxCUHeight,
223 const UInt maxTotalCUDepth,
272 const UInt uiNumPartitions = 1<<(maxTotalCUDepth<<1);
278 #if ADAPTIVE_QP_SELECTION
283 for (
UInt layer = 0; layer < uiNumLayersToAllocate; layer++)
286 #if ADAPTIVE_QP_SELECTION
294 #if ADAPTIVE_QP_SELECTION
301 for(
UInt ui = 0; ui < uiNumLayersToAllocate; ++ui )
315 const Pel*
const piRefSrch = rcStruct.
piRefY + iSearchY * rcStruct.
iYStride + iSearchX;
353 if((uiTempSad + uiBitCost) < rcStruct.
uiBestSad)
363 if(((uiSad << isubShift) + uiBitCost) > rcStruct.
uiBestSad)
377 rcStruct.
iBestX = iSearchX;
378 rcStruct.
iBestY = iSearchY;
411 rcStruct.
iBestX = iSearchX;
412 rcStruct.
iBestY = iSearchY;
424 Int iSrchRngHorLeft = pcMvSrchRngLT->
getHor();
425 Int iSrchRngHorRight = pcMvSrchRngRB->
getHor();
426 Int iSrchRngVerTop = pcMvSrchRngLT->
getVer();
427 Int iSrchRngVerBottom = pcMvSrchRngRB->
getVer();
438 if ( (iStartX - 1) >= iSrchRngHorLeft )
440 xTZSearchHelp( pcPatternKey, rcStruct, iStartX - 1, iStartY, 0, 2 );
442 if ( (iStartY - 1) >= iSrchRngVerTop )
444 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iStartY - 1, 0, 2 );
450 if ( (iStartY - 1) >= iSrchRngVerTop )
452 if ( (iStartX - 1) >= iSrchRngHorLeft )
454 xTZSearchHelp( pcPatternKey, rcStruct, iStartX - 1, iStartY - 1, 0, 2 );
456 if ( (iStartX + 1) <= iSrchRngHorRight )
458 xTZSearchHelp( pcPatternKey, rcStruct, iStartX + 1, iStartY - 1, 0, 2 );
465 if ( (iStartY - 1) >= iSrchRngVerTop )
467 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iStartY - 1, 0, 2 );
469 if ( (iStartX + 1) <= iSrchRngHorRight )
471 xTZSearchHelp( pcPatternKey, rcStruct, iStartX + 1, iStartY, 0, 2 );
477 if ( (iStartX - 1) >= iSrchRngHorLeft )
479 if ( (iStartY + 1) <= iSrchRngVerBottom )
481 xTZSearchHelp( pcPatternKey, rcStruct, iStartX - 1, iStartY + 1, 0, 2 );
483 if ( (iStartY - 1) >= iSrchRngVerTop )
485 xTZSearchHelp( pcPatternKey, rcStruct, iStartX - 1, iStartY - 1, 0, 2 );
492 if ( (iStartX + 1) <= iSrchRngHorRight )
494 if ( (iStartY - 1) >= iSrchRngVerTop )
496 xTZSearchHelp( pcPatternKey, rcStruct, iStartX + 1, iStartY - 1, 0, 2 );
498 if ( (iStartY + 1) <= iSrchRngVerBottom )
500 xTZSearchHelp( pcPatternKey, rcStruct, iStartX + 1, iStartY + 1, 0, 2 );
507 if ( (iStartX - 1) >= iSrchRngHorLeft )
509 xTZSearchHelp( pcPatternKey, rcStruct, iStartX - 1, iStartY , 0, 2 );
511 if ( (iStartY + 1) <= iSrchRngVerBottom )
513 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iStartY + 1, 0, 2 );
519 if ( (iStartY + 1) <= iSrchRngVerBottom )
521 if ( (iStartX - 1) >= iSrchRngHorLeft )
523 xTZSearchHelp( pcPatternKey, rcStruct, iStartX - 1, iStartY + 1, 0, 2 );
525 if ( (iStartX + 1) <= iSrchRngHorRight )
527 xTZSearchHelp( pcPatternKey, rcStruct, iStartX + 1, iStartY + 1, 0, 2 );
534 if ( (iStartX + 1) <= iSrchRngHorRight )
536 xTZSearchHelp( pcPatternKey, rcStruct, iStartX + 1, iStartY, 0, 2 );
538 if ( (iStartY + 1) <= iSrchRngVerBottom )
540 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iStartY + 1, 0, 2 );
557 const Int iSrchRngHorLeft = pcMvSrchRngLT->
getHor();
558 const Int iSrchRngHorRight = pcMvSrchRngRB->
getHor();
559 const Int iSrchRngVerTop = pcMvSrchRngLT->
getVer();
560 const Int iSrchRngVerBottom = pcMvSrchRngRB->
getVer();
565 assert( iDist != 0 );
566 const Int iTop = iStartY - iDist;
567 const Int iBottom = iStartY + iDist;
568 const Int iLeft = iStartX - iDist;
569 const Int iRight = iStartX + iDist;
572 if ( iTop >= iSrchRngVerTop )
574 if ( iLeft >= iSrchRngHorLeft )
576 xTZSearchHelp( pcPatternKey, rcStruct, iLeft, iTop, 1, iDist );
579 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iTop, 2, iDist );
581 if ( iRight <= iSrchRngHorRight )
583 xTZSearchHelp( pcPatternKey, rcStruct, iRight, iTop, 3, iDist );
586 if ( iLeft >= iSrchRngHorLeft )
588 xTZSearchHelp( pcPatternKey, rcStruct, iLeft, iStartY, 4, iDist );
590 if ( iRight <= iSrchRngHorRight )
592 xTZSearchHelp( pcPatternKey, rcStruct, iRight, iStartY, 5, iDist );
594 if ( iBottom <= iSrchRngVerBottom )
596 if ( iLeft >= iSrchRngHorLeft )
598 xTZSearchHelp( pcPatternKey, rcStruct, iLeft, iBottom, 6, iDist );
601 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iBottom, 7, iDist );
603 if ( iRight <= iSrchRngHorRight )
605 xTZSearchHelp( pcPatternKey, rcStruct, iRight, iBottom, 8, iDist );
615 const TComMv*
const pcMvSrchRngLT,
616 const TComMv*
const pcMvSrchRngRB,
620 const Bool bCheckCornersAtDist1 )
622 const Int iSrchRngHorLeft = pcMvSrchRngLT->
getHor();
623 const Int iSrchRngHorRight = pcMvSrchRngRB->
getHor();
624 const Int iSrchRngVerTop = pcMvSrchRngLT->
getVer();
625 const Int iSrchRngVerBottom = pcMvSrchRngRB->
getVer();
630 assert ( iDist != 0 );
631 const Int iTop = iStartY - iDist;
632 const Int iBottom = iStartY + iDist;
633 const Int iLeft = iStartX - iDist;
634 const Int iRight = iStartX + iDist;
639 if ( iTop >= iSrchRngVerTop )
641 if (bCheckCornersAtDist1)
643 if ( iLeft >= iSrchRngHorLeft)
645 xTZSearchHelp( pcPatternKey, rcStruct, iLeft, iTop, 1, iDist );
647 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iTop, 2, iDist );
648 if ( iRight <= iSrchRngHorRight )
650 xTZSearchHelp( pcPatternKey, rcStruct, iRight, iTop, 3, iDist );
655 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iTop, 2, iDist );
658 if ( iLeft >= iSrchRngHorLeft )
660 xTZSearchHelp( pcPatternKey, rcStruct, iLeft, iStartY, 4, iDist );
662 if ( iRight <= iSrchRngHorRight )
664 xTZSearchHelp( pcPatternKey, rcStruct, iRight, iStartY, 5, iDist );
666 if ( iBottom <= iSrchRngVerBottom )
668 if (bCheckCornersAtDist1)
670 if ( iLeft >= iSrchRngHorLeft)
672 xTZSearchHelp( pcPatternKey, rcStruct, iLeft, iBottom, 6, iDist );
674 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iBottom, 7, iDist );
675 if ( iRight <= iSrchRngHorRight )
677 xTZSearchHelp( pcPatternKey, rcStruct, iRight, iBottom, 8, iDist );
682 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iBottom, 7, iDist );
690 const Int iTop_2 = iStartY - (iDist>>1);
691 const Int iBottom_2 = iStartY + (iDist>>1);
692 const Int iLeft_2 = iStartX - (iDist>>1);
693 const Int iRight_2 = iStartX + (iDist>>1);
695 if ( iTop >= iSrchRngVerTop && iLeft >= iSrchRngHorLeft &&
696 iRight <= iSrchRngHorRight && iBottom <= iSrchRngVerBottom )
698 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iTop, 2, iDist );
699 xTZSearchHelp( pcPatternKey, rcStruct, iLeft_2, iTop_2, 1, iDist>>1 );
700 xTZSearchHelp( pcPatternKey, rcStruct, iRight_2, iTop_2, 3, iDist>>1 );
701 xTZSearchHelp( pcPatternKey, rcStruct, iLeft, iStartY, 4, iDist );
702 xTZSearchHelp( pcPatternKey, rcStruct, iRight, iStartY, 5, iDist );
703 xTZSearchHelp( pcPatternKey, rcStruct, iLeft_2, iBottom_2, 6, iDist>>1 );
704 xTZSearchHelp( pcPatternKey, rcStruct, iRight_2, iBottom_2, 8, iDist>>1 );
705 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iBottom, 7, iDist );
709 if ( iTop >= iSrchRngVerTop )
711 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iTop, 2, iDist );
713 if ( iTop_2 >= iSrchRngVerTop )
715 if ( iLeft_2 >= iSrchRngHorLeft )
717 xTZSearchHelp( pcPatternKey, rcStruct, iLeft_2, iTop_2, 1, (iDist>>1) );
719 if ( iRight_2 <= iSrchRngHorRight )
721 xTZSearchHelp( pcPatternKey, rcStruct, iRight_2, iTop_2, 3, (iDist>>1) );
724 if ( iLeft >= iSrchRngHorLeft )
726 xTZSearchHelp( pcPatternKey, rcStruct, iLeft, iStartY, 4, iDist );
728 if ( iRight <= iSrchRngHorRight )
730 xTZSearchHelp( pcPatternKey, rcStruct, iRight, iStartY, 5, iDist );
732 if ( iBottom_2 <= iSrchRngVerBottom )
734 if ( iLeft_2 >= iSrchRngHorLeft )
736 xTZSearchHelp( pcPatternKey, rcStruct, iLeft_2, iBottom_2, 6, (iDist>>1) );
738 if ( iRight_2 <= iSrchRngHorRight )
740 xTZSearchHelp( pcPatternKey, rcStruct, iRight_2, iBottom_2, 8, (iDist>>1) );
743 if ( iBottom <= iSrchRngVerBottom )
745 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iBottom, 7, iDist );
751 if ( iTop >= iSrchRngVerTop && iLeft >= iSrchRngHorLeft &&
752 iRight <= iSrchRngHorRight && iBottom <= iSrchRngVerBottom )
754 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iTop, 0, iDist );
755 xTZSearchHelp( pcPatternKey, rcStruct, iLeft, iStartY, 0, iDist );
756 xTZSearchHelp( pcPatternKey, rcStruct, iRight, iStartY, 0, iDist );
757 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iBottom, 0, iDist );
758 for (
Int index = 1; index < 4; index++ )
760 const Int iPosYT = iTop + ((iDist>>2) * index);
761 const Int iPosYB = iBottom - ((iDist>>2) * index);
762 const Int iPosXL = iStartX - ((iDist>>2) * index);
763 const Int iPosXR = iStartX + ((iDist>>2) * index);
764 xTZSearchHelp( pcPatternKey, rcStruct, iPosXL, iPosYT, 0, iDist );
765 xTZSearchHelp( pcPatternKey, rcStruct, iPosXR, iPosYT, 0, iDist );
766 xTZSearchHelp( pcPatternKey, rcStruct, iPosXL, iPosYB, 0, iDist );
767 xTZSearchHelp( pcPatternKey, rcStruct, iPosXR, iPosYB, 0, iDist );
772 if ( iTop >= iSrchRngVerTop )
774 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iTop, 0, iDist );
776 if ( iLeft >= iSrchRngHorLeft )
778 xTZSearchHelp( pcPatternKey, rcStruct, iLeft, iStartY, 0, iDist );
780 if ( iRight <= iSrchRngHorRight )
782 xTZSearchHelp( pcPatternKey, rcStruct, iRight, iStartY, 0, iDist );
784 if ( iBottom <= iSrchRngVerBottom )
786 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iBottom, 0, iDist );
788 for (
Int index = 1; index < 4; index++ )
790 const Int iPosYT = iTop + ((iDist>>2) * index);
791 const Int iPosYB = iBottom - ((iDist>>2) * index);
792 const Int iPosXL = iStartX - ((iDist>>2) * index);
793 const Int iPosXR = iStartX + ((iDist>>2) * index);
795 if ( iPosYT >= iSrchRngVerTop )
797 if ( iPosXL >= iSrchRngHorLeft )
799 xTZSearchHelp( pcPatternKey, rcStruct, iPosXL, iPosYT, 0, iDist );
801 if ( iPosXR <= iSrchRngHorRight )
803 xTZSearchHelp( pcPatternKey, rcStruct, iPosXR, iPosYT, 0, iDist );
806 if ( iPosYB <= iSrchRngVerBottom )
808 if ( iPosXL >= iSrchRngHorLeft )
810 xTZSearchHelp( pcPatternKey, rcStruct, iPosXL, iPosYB, 0, iDist );
812 if ( iPosXR <= iSrchRngHorRight )
814 xTZSearchHelp( pcPatternKey, rcStruct, iPosXR, iPosYB, 0, iDist );
826 Bool bAllowUseOfHadamard
830 Distortion uiDistBest = std::numeric_limits<Distortion>::max();
831 UInt uiDirecBest = 0;
841 UInt maxRefinements = 9;
845 const UInt LumaLTSampleOffset = 3;
846 const UInt LumaRBSampleOffset = 4;
862 for (
UInt i = 0; i < maxRefinements; i++)
864 for (
UInt i = 0; i < 9; i++)
867 TComMv cMvTest = pcMvRefine[i];
868 cMvTest += baseRefMv;
873 if ( horVal == 2 && ( verVal & 1 ) == 0 )
877 if ( ( horVal & 1 ) == 0 && verVal == 2 )
879 piRefPos += iRefStride;
881 cMvTest = pcMvRefine[i];
891 if ( uiDist < uiDistBest )
899 rcMvFrac = pcMvRefine[uiDirecBest];
915 const UInt uiSubdiv = ( uiTrMode > uiTrDepth ? 1 : 0 );
987 const UInt uiSubdiv = ( uiTrMode > uiTrDepth ? 1 : 0 );
994 xEncCoeffQT( tuRecurseChild, component, bRealCoeff );
1027 if( uiAbsPartIdx == 0 )
1053 if (uiAbsPartIdx==0)
1061 if (uiTrDepth>0 && (uiAbsPartIdx%uiQNumParts)==0)
1080 assert(uiTrDepth>0);
1081 if ((uiAbsPartIdx%uiQNumParts)==0)
1133 const Bool checkCrossCPrediction,
1138 ,
Int default0Save1Load2
1141 if (!rTu.ProcessComponentSection(compID))
1148 const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU();
1151 const UInt uiTrDepth = rTu.GetTransformDepthRelAdj(compID);
1152 const UInt uiFullDepth = rTu.GetTransformDepthTotal();
1153 const UInt uiLog2TrSize = rTu.GetLog2LumaTrSize();
1161 Pel *piOrg = pcOrgYuv ->
getAddr( compID, uiAbsPartIdx );
1162 Pel *piPred = pcPredYuv->
getAddr( compID, uiAbsPartIdx );
1163 Pel *piResi = pcResiYuv->
getAddr( compID, uiAbsPartIdx );
1164 Pel *piReco = pcPredYuv->
getAddr( compID, uiAbsPartIdx );
1174 #if ADAPTIVE_QP_SELECTION
1190 Pel *
const lumaResidualForEstimate = bUseReconstructedResidualForEstimate ? reconstructedLumaResidual : encoderLumaResidual;
1193 const Int debugPredModeMask=DebugStringGetPredModeMask(
MODE_INTRA);
1200 if( default0Save1Load2 != 2 )
1208 predIntraAng( compID, uiChFinalMode, piOrg, uiStride, piPred, uiStride, rTu, bUseFilteredPredictions );
1211 if( default0Save1Load2 == 1 )
1213 Pel* pPred = piPred;
1216 for(
UInt uiY = 0; uiY < uiHeight; uiY++ )
1218 for(
UInt uiX = 0; uiX < uiWidth; uiX++ )
1220 pPredBuf[ k ++ ] = pPred[ uiX ];
1230 Pel* pPred = piPred;
1233 for(
UInt uiY = 0; uiY < uiHeight; uiY++ )
1235 for(
UInt uiX = 0; uiX < uiWidth; uiX++ )
1237 pPred[ uiX ] = pPredBuf[ k ++ ];
1248 Pel* pPred = piPred;
1249 Pel* pResi = piResi;
1251 for(
UInt uiY = 0; uiY < uiHeight; uiY++ )
1253 for(
UInt uiX = 0; uiX < uiWidth; uiX++ )
1255 pResi[ uiX ] = pOrg[ uiX ] - pPred[ uiX ];
1266 if (bUseCrossCPrediction)
1272 TComTrQuant::crossComponentPrediction ( rTu, compID, reconstructedLumaResidual, piResi, piResi, uiWidth, uiHeight, MAX_CU_SIZE, uiStride, uiStride,
false );
1274 else if (
isLuma(compID) && !bUseReconstructedResidualForEstimate)
1295 const QpParam cQP(*pcCU, compID);
1297 #if RDOQ_CHROMA_LAMBDA
1311 if ( (uiAbsSum > 0) || (DebugOptionList::DebugString_InvTran.getInt()&debugPredModeMask) )
1320 Pel* pResi = piResi;
1321 memset( pcCoeff, 0,
sizeof(
TCoeff ) * uiWidth * uiHeight );
1322 for(
UInt uiY = 0; uiY < uiHeight; uiY++ )
1324 memset( pResi, 0,
sizeof(
Pel ) * uiWidth );
1332 Pel* pPred = piPred;
1333 Pel* pResi = piResi;
1334 Pel* pReco = piReco;
1335 Pel* pRecQt = piRecQt;
1336 Pel* pRecIPred = piRecIPred;
1340 if (bUseCrossCPrediction)
1342 TComTrQuant::crossComponentPrediction( rTu, compID, reconstructedLumaResidual, piResi, piResi, uiWidth, uiHeight, MAX_CU_SIZE, uiStride, uiStride,
true );
1351 std::stringstream ss(stringstream::out);
1356 if (bDebugPred || bDebugResi || bDebugReco)
1358 ss <<
"###: " <<
"CompID: " << compID <<
" pred mode (ch/fin): " << uiChPredMode <<
"/" << uiChFinalMode <<
" absPartIdx: " << rTu.GetAbsPartIdxTU() <<
"\n";
1359 for(
UInt uiY = 0; uiY < uiHeight; uiY++ )
1365 for(
UInt uiX = 0; uiX < uiWidth; uiX++ )
1367 ss << pPred[ uiX ] <<
", ";
1374 for(
UInt uiX = 0; uiX < uiWidth; uiX++ )
1378 ss << pResi[ uiX ] <<
", ";
1380 pReco [ uiX ] =
Pel(ClipBD<Int>(
Int(pPred[uiX]) +
Int(pResi[uiX]), bitDepth ));
1381 pRecQt [ uiX ] = pReco[ uiX ];
1382 pRecIPred[ uiX ] = pReco[ uiX ];
1387 for(
UInt uiX = 0; uiX < uiWidth; uiX++ )
1389 ss << pReco[ uiX ] <<
", ";
1395 pRecQt += uiRecQtStride;
1396 pRecIPred += uiRecIPredStride;
1405 for(
UInt uiY = 0; uiY < uiHeight; uiY++ )
1407 for(
UInt uiX = 0; uiX < uiWidth; uiX++ )
1409 pReco [ uiX ] =
Pel(ClipBD<Int>(
Int(pPred[uiX]) +
Int(pResi[uiX]), bitDepth ));
1410 pRecQt [ uiX ] = pReco[ uiX ];
1411 pRecIPred[ uiX ] = pReco[ uiX ];
1416 pRecQt += uiRecQtStride;
1417 pRecIPred += uiRecIPredStride;
1423 ruiDist +=
m_pcRdCost->
getDistPart( bitDepth, piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight, compID );
1443 const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU();
1444 const UInt uiFullDepth = rTu.GetTransformDepthTotal();
1445 const UInt uiTrDepth = rTu.GetTransformDepthRel();
1446 const UInt uiLog2TrSize = rTu.GetLog2LumaTrSize();
1456 bMaintainResidual[residualTypeIndex] =
true;
1461 #if HHI_RQT_INTRA_SPEEDUP
1465 Bool noSplitIntraMaxTuSize = bCheckFull;
1469 noSplitIntraMaxTuSize = ( uiLog2TrSize <= min(maxTuSize,4) );
1474 bCheckFull = ( uiLog2TrSize <= min(maxTuSize,4));
1477 if( bCheckFirst && noSplitIntraMaxTuSize )
1480 bCheckSplit =
false;
1488 bCheckFull = ( uiLog2TrSize <= min(maxTuSize,4));
1493 UInt uiSingleCbfLuma = 0;
1499 assert (rTu.ProcessComponentSection(
COMPONENT_Y));
1500 const UInt totalAdjustedDepthChan = rTu.GetTransformDepthTotalAdj(
COMPONENT_Y);
1509 if(checkTransformSkip ==
true)
1515 UInt singleCbfTmpLuma = 0;
1516 Double singleCostTmp = 0;
1517 Int firstCheckId = 0;
1519 for(
Int modeId = firstCheckId; modeId < 2; modeId ++)
1522 Int default0Save1Load2 = 0;
1523 singleDistTmpLuma=0;
1524 if(modeId == firstCheckId)
1526 default0Save1Load2 = 1;
1530 default0Save1Load2 = 2;
1540 if(modeId == 1 && singleCbfTmpLuma == 0)
1550 if(singleCostTmp < dSingleCost)
1553 dSingleCost = singleCostTmp;
1554 uiSingleDistLuma = singleDistTmpLuma;
1555 uiSingleCbfLuma = singleCbfTmpLuma;
1570 if (bMaintainResidual[storedResidualIndex])
1577 if (modeId == firstCheckId)
1585 if(bestModeId[COMPONENT_Y] == firstCheckId)
1588 pcCU->
setCbfSubParts ( uiSingleCbfLuma << uiTrDepth, COMPONENT_Y, uiAbsPartIdx, rTu.GetTransformDepthTotalAdj(COMPONENT_Y) );
1615 uiSingleBits=uiSingleBits*4;
1626 if (bMaintainResidual[storedResidualIndex])
1650 UInt uiSplitCbfLuma = 0;
1657 #if HHI_RQT_INTRA_SPEEDUP
1666 UInt uiPartsDiv = rTu.GetAbsPartIdxNumParts();
1670 const UInt flag=1<<uiTrDepth;
1672 for(
UInt uiOffs = 0; uiOffs < uiPartsDiv; uiOffs++ )
1674 pBase[ uiAbsPartIdx + uiOffs ] |= flag;
1686 if( dSplitCost < dSingleCost )
1690 ruiDistY += uiSplitDistLuma;
1691 dRDCost += dSplitCost;
1699 if (bMaintainResidual[storedResidualIndex])
1728 for(
UInt uiY = 0; uiY < uiHeight; uiY++, piSrc += uiSrcStride, piDes += uiDesStride )
1730 for(
UInt uiX = 0; uiX < uiWidth; uiX++ )
1732 piDes[ uiX ] = piSrc[ uiX ];
1736 ruiDistY += uiSingleDistLuma;
1737 dRDCost += dSingleCost;
1748 if( uiTrMode == uiTrDepth )
1759 if (numCoeffInBlock!=0)
1763 ::memcpy( destCoeff, srcCoeff,
sizeof(
TCoeff)*numCoeffInBlock );
1764 #if ADAPTIVE_QP_SELECTION
1767 ::memcpy( destArlCoeff, srcArlCoeff,
sizeof(
TCoeff ) * numCoeffInBlock );
1791 if ( compID==
COMPONENT_Y || uiTrMode == uiTrDepth )
1793 assert(uiTrMode == uiTrDepth);
1806 ::memcpy( pcCoeffDst, pcCoeffSrc,
sizeof(
TCoeff ) * uiNumCoeff );
1807 #if ADAPTIVE_QP_SELECTION
1810 ::memcpy( pcArlCoeffDst, pcArlCoeffSrc,
sizeof(
TCoeff ) * uiNumCoeff );
1826 if ( compID==
COMPONENT_Y || uiTrMode == uiTrDepth )
1828 assert(uiTrMode == uiTrDepth);
1842 ::memcpy( pcCoeffDst, pcCoeffSrc,
sizeof(
TCoeff ) * uiNumCoeff );
1843 #if ADAPTIVE_QP_SELECTION
1846 ::memcpy( pcArlCoeffDst, pcArlCoeffSrc,
sizeof(
TCoeff ) * uiNumCoeff );
1857 Pel* pRecQt = piRecQt;
1858 Pel* pRecIPred = piRecIPred;
1859 for(
UInt uiY = 0; uiY < uiHeight; uiY++ )
1861 for(
UInt uiX = 0; uiX < uiWidth; uiX++ )
1863 pRecIPred[ uiX ] = pRecQt [ uiX ];
1865 pRecQt += uiRecQtStride;
1866 pRecIPred += uiRecIPredStride;
1874 const Pel *pResiSrc,
1878 const Int strideDst,
1879 const Int strideSrc )
1881 const Pel *pSrc = pResiSrc + yOffset * strideSrc + xOffset;
1882 Pel *pDst = pResiDst + yOffset * strideDst + xOffset;
1902 const Pel *pResiL = piResiL;
1903 const Pel *pResiC = piResiC;
1913 for(
UInt uiY = 0; uiY < height; uiY++ )
1915 for(
UInt uiX = 0; uiX < width; uiX++ )
1917 const Pel scaledResiL =
rightShift( pResiL[ uiX ], diffBitDepth );
1918 SSxy += ( scaledResiL * pResiC[ uiX ] );
1919 SSxx += ( scaledResiL * scaledResiL );
1929 alpha =
SChar(Clip3<Int>(-16, 16, (
Int)(dAlpha * 16)));
1931 static const SChar alphaQuant[17] = {0, 1, 1, 2, 2, 2, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8};
1933 alpha = (alpha < 0) ? -alphaQuant[
Int(-alpha)] : alphaQuant[
Int(alpha)];
1950 const UInt uiTrDepth = rTu.GetTransformDepthRel();
1951 const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU();
1956 if( uiTrMode == uiTrDepth )
1963 const UInt uiFullDepth = rTu.GetTransformDepthTotal();
1972 if (checkTransformSkip)
1975 const UInt maxAbsPartIdxSub=uiAbsPartIdx + (rTu.ProcessingAllQuadrants(
COMPONENT_Cb)?1:4);
1976 for(
UInt absPartIdxSub = uiAbsPartIdx; absPartIdxSub < maxAbsPartIdxSub; absPartIdxSub ++)
1980 checkTransformSkip &= (nbLumaSkip > 0);
1993 const Bool splitIntoSubTUs = rTu.getRect(compID).width != rTu.getRect(compID).height;
2006 UInt singleCbfC = 0;
2008 Double singleCostTmp = 0;
2009 UInt singleCbfCTmp = 0;
2010 SChar bestCrossCPredictionAlpha = 0;
2011 Int bestTransformSkipMode = 0;
2017 const Int crossCPredictionModesToTest = checkCrossComponentPrediction ? 2 : 1;
2018 const Int transformSkipModesToTest = checkTransformSkip ? 2 : 1;
2019 const Int totalModesToTest = crossCPredictionModesToTest * transformSkipModesToTest;
2021 Int default0Save1Load2 = 0;
2023 for(
Int transformSkipModeId = 0; transformSkipModeId < transformSkipModesToTest; transformSkipModeId++)
2025 for(
Int crossCPredictionModeId = 0; crossCPredictionModeId < crossCPredictionModesToTest; crossCPredictionModeId++)
2032 const Bool isOneMode = (totalModesToTest == 1);
2033 const Bool isLastMode = (currModeId == totalModesToTest);
2037 default0Save1Load2 = 0;
2039 else if (!isOneMode && (transformSkipModeId == 0) && (crossCPredictionModeId == 0))
2041 default0Save1Load2 = 1;
2045 default0Save1Load2 = 2;
2051 singleCbfCTmp = pcCU->
getCbf( subTUAbsPartIdx, compID, uiTrDepth);
2054 || ((transformSkipModeId == 1) && (singleCbfCTmp == 0)))
2058 else if (!isOneMode)
2064 if(singleCostTmp < dSingleCost)
2067 dSingleCost = singleCostTmp;
2068 singleDistC = singleDistCTmp;
2070 bestTransformSkipMode = transformSkipModeId;
2071 bestModeId = currModeId;
2072 singleCbfC = singleCbfCTmp;
2074 if (!isOneMode && !isLastMode)
2081 if (!isOneMode && !isLastMode)
2088 if(bestModeId < totalModesToTest)
2091 pcCU->
setCbfPartRange( singleCbfC << uiTrDepth, compID, subTUAbsPartIdx, partIdxesPerSubTU );
2099 ruiDist += singleDistC;
2102 if (splitIntoSubTUs)
2125 uiSplitCbf[ch] |= pcCU->
getCbf( uiAbsPartIdxSub,
ComponentID(ch), uiTrDepthChild );
2130 UInt uiPartsDiv = rTu.GetAbsPartIdxNumParts();
2135 const UInt flag=1<<uiTrDepth;
2138 for(
UInt uiOffs = 0; uiOffs < uiPartsDiv; uiOffs++ )
2140 pBase[ uiAbsPartIdx + uiOffs ] |= flag;
2161 if( uiTrMode == uiTrDepth )
2177 ::memcpy( dest, src,
sizeof(
TCoeff)*uiNumCoeffC );
2178 #if ADAPTIVE_QP_SELECTION
2181 ::memcpy( pcArlCoeffDst, pcArlCoeffSrc,
sizeof(
TCoeff ) * uiNumCoeffC );
2213 const UInt uiNumPU = 1<<(2*uiInitTrDepth);
2228 bMaintainResidual[residualTypeIndex] =
true;
2267 Int numModesAvailable = 35;
2275 Bool doFastSearch = (numModesForFullRD != numModesAvailable);
2278 assert(numModesForFullRD < numModesAvailable);
2280 for(
Int i=0; i < numModesForFullRD; i++ )
2296 for(
Int modeIdx = 0; modeIdx < numModesAvailable; modeIdx++ )
2298 UInt uiMode = modeIdx;
2306 uiSad+=distParam.
DistFunc(&distParam);
2315 #if DEBUG_INTRA_SEARCH_COSTS
2316 std::cout <<
"1st pass mode " << uiMode <<
" SAD = " << uiSad <<
", mode bits = " << iModeBits <<
", cost = " << cost <<
"\n";
2319 CandNum +=
xUpdateCandList( uiMode, cost, numModesForFullRD, uiRdModeList, CandCostList );
2331 for(
Int j=0; j < numCand; j++)
2333 Bool mostProbableModeIncluded =
false;
2334 Int mostProbableMode = uiPreds[j];
2336 for(
Int i=0; i < numModesForFullRD; i++)
2338 mostProbableModeIncluded |= (mostProbableMode == uiRdModeList[i]);
2340 if (!mostProbableModeIncluded)
2342 uiRdModeList[numModesForFullRD++] = mostProbableMode;
2349 for(
Int i=0; i < numModesForFullRD; i++)
2351 uiRdModeList[i] = i;
2356 #if HHI_RQT_INTRA_SPEEDUP_MOD
2361 UInt uiBestPUMode = 0;
2365 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
2366 UInt max=numModesForFullRD;
2372 for (
UInt uiMode = 0; uiMode < max; uiMode++)
2374 for(
UInt uiMode = 0; uiMode < numModesForFullRD; uiMode++ )
2378 UInt uiOrgMode = uiRdModeList[uiMode];
2389 #if HHI_RQT_INTRA_SPEEDUP
2395 #if DEBUG_INTRA_SEARCH_COSTS
2400 if( dPUCost < dBestPUCost )
2403 #if HHI_RQT_INTRA_SPEEDUP_MOD
2404 uiSecondBestMode = uiBestPUMode;
2405 dSecondBestPUCost = dBestPUCost;
2407 uiBestPUMode = uiOrgMode;
2408 uiBestPUDistY = uiPUDistY;
2409 dBestPUCost = dPUCost;
2419 if (bMaintainResidual[storedResidualIndex])
2429 for (
UInt component = 0; component < numberValidComponents; component++)
2436 #if HHI_RQT_INTRA_SPEEDUP_MOD
2437 else if( dPUCost < dSecondBestPUCost )
2439 uiSecondBestMode = uiOrgMode;
2440 dSecondBestPUCost = dPUCost;
2445 #if HHI_RQT_INTRA_SPEEDUP
2446 #if HHI_RQT_INTRA_SPEEDUP_MOD
2447 for(
UInt ui =0; ui < 2; ++ui )
2450 #if HHI_RQT_INTRA_SPEEDUP_MOD
2451 UInt uiOrgMode = ui ? uiSecondBestMode : uiBestPUMode;
2457 UInt uiOrgMode = uiBestPUMode;
2460 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
2480 if( dPUCost < dBestPUCost )
2483 uiBestPUMode = uiOrgMode;
2484 uiBestPUDistY = uiPUDistY;
2485 dBestPUCost = dPUCost;
2495 if (bMaintainResidual[storedResidualIndex])
2505 for (
UInt component = 0; component < numberValidComponents; component++)
2518 uiOverallDistY += uiBestPUDistY;
2523 for (
UInt component = 0; component < numberValidComponents; component++)
2543 for(
UInt uiY = 0; uiY < uiCompHeight; uiY++, piSrc += uiSrcStride, piDes += uiDesStride )
2545 for(
UInt uiX = 0; uiX < uiCompWidth; uiX++ )
2547 piDes[ uiX ] = piSrc[ uiX ];
2554 }
while (tuRecurseWithPU.
nextSection(tuRecurseCU));
2559 UInt uiCombCbfY = 0;
2560 UInt uiCombCbfU = 0;
2561 UInt uiCombCbfV = 0;
2563 for(
UInt uiPart = 0; uiPart < 4; uiPart++, uiPartIdx += uiQNumParts )
2569 for(
UInt uiOffs = 0; uiOffs < 4 * uiQNumParts; uiOffs++ )
2606 UInt uiBestMode = 0;
2614 const UInt uiQPartNum = uiQNumParts;
2623 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
2627 if (uiModeList[uiMinMode]==34)
2631 uiMaxMode=uiMinMode+1;
2637 for(
UInt uiMode = uiMinMode; uiMode < uiMaxMode; uiMode++ )
2657 if( dCost < dBestCost )
2661 uiBestDist = uiDist;
2662 uiBestMode = uiModeList[uiMode];
2665 for (
UInt componentIndex =
COMPONENT_Cb; componentIndex < numberValidComponents; componentIndex++)
2678 for (
UInt componentIndex =
COMPONENT_Cb; componentIndex < numberValidComponents; componentIndex++)
2698 const Pel* piSrc = pcRecoYuv->
getAddr( compID, uiPartOffset );
2701 for(
UInt uiY = 0; uiY < uiCompHeight; uiY++, piSrc += uiSrcStride, piDes += uiDesStride )
2703 for(
UInt uiX = 0; uiX < uiCompWidth; uiX++ )
2705 piDes[ uiX ] = piSrc[ uiX ];
2715 }
while (tuRecurseWithPU.
nextSection(tuRecurseCU));
2719 if( uiInitTrDepth != 0 )
2721 UInt uiCombCbfU = 0;
2722 UInt uiCombCbfV = 0;
2724 for(
UInt uiPart = 0; uiPart < 4; uiPart++, uiPartIdx += uiQNumParts )
2729 for(
UInt uiOffs = 0; uiOffs < 4 * uiQNumParts; uiOffs++ )
2755 Void TEncSearch::xEncPCM (
TComDataCU* pcCU,
UInt uiAbsPartIdx,
Pel* pOrg,
Pel* pPCM,
Pel* pPred,
Pel* pResi,
Pel* pReco,
UInt uiStride,
UInt uiWidth,
UInt uiHeight,
const ComponentID compID )
2762 const Int pcmShiftRight=(channelBitDepth -
Int(uiPCMBitDepth));
2764 assert(pcmShiftRight >= 0);
2766 for(
UInt uiY = 0; uiY < uiHeight; uiY++ )
2768 for(
UInt uiX = 0; uiX < uiWidth; uiX++ )
2774 pPCM[uiX] = (pOrg[uiX]>>pcmShiftRight);
2776 pReco [uiX] = (pPCM[uiX]<<(pcmShiftRight));
2777 pRecoPic[uiX] = pReco[uiX];
2784 pRecoPic += uiReconStride;
2805 Pel * pOrig = pcOrgYuv->
getAddr (compID, 0, width);
2806 Pel * pResi = pcResiYuv->
getAddr(compID, 0, width);
2807 Pel * pPred = pcPredYuv->
getAddr(compID, 0, width);
2808 Pel * pReco = pcRecoYuv->
getAddr(compID, 0, width);
2811 xEncPCM ( pcCU, 0, pOrig, pPCM, pPred, pResi, pReco, stride, width, height, compID );
2837 UInt uiAbsPartIdx = 0;
2852 ruiErr = cDistParam.
DistFunc( &cDistParam );
2858 UInt uiAbsPartIdx = 0;
2872 UInt numSpatialMergeCandidates = 0;
2873 pcCU->
getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, numSpatialMergeCandidates );
2876 numValidMergeCand = numSpatialMergeCandidates;
2887 UInt numSpatialMergeCandidates = 0;
2888 pcCU->
getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, numSpatialMergeCandidates );
2891 numValidMergeCand = numSpatialMergeCandidates;
2894 pcCU->
getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
2900 ruiCost = std::numeric_limits<Distortion>::max();
2901 for(
UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand )
2903 Distortion uiCostCand = std::numeric_limits<Distortion>::max();
2904 UInt uiBitsCand = 0;
2912 uiBitsCand = uiMergeCand + 1;
2918 if ( uiCostCand < ruiCost )
2920 ruiCost = uiCostCand;
2921 pacMvField[0] = cMvFieldNeighbours[0 + 2*uiMergeCand];
2922 pacMvField[1] = cMvFieldNeighbours[1 + 2*uiMergeCand];
2923 uiInterDir = uhInterDirNeighbours[uiMergeCand];
2924 uiMergeIndex = uiMergeCand;
2941 for(
UInt mergeCand = 0; mergeCand < numValidMergeCand; ++mergeCand )
2943 if ( interDirNeighbours[mergeCand] == 3 )
2945 interDirNeighbours[mergeCand] = 1;
2946 mvFieldNeighbours[(mergeCand << 1) + 1].setMvField(
TComMv(0,0), -1);
2989 Int aaiMvpIdxBi[2][33];
2991 Int aaiMvpIdx[2][33];
2992 Int aaiMvpNum[2][33];
2996 Int iRefIdx[2]={0,0};
3000 Int iRoiWidth, iRoiHeight;
3002 UInt uiMbBits[3] = {1, 1, 0};
3004 UInt uiLastMode = 0;
3005 Int iRefStart, iRefEnd;
3009 Int bestBiPRefIdxL1 = 0;
3010 Int bestBiPMvpL1 = 0;
3011 Distortion biPDistTemp = std::numeric_limits<Distortion>::max();
3015 Int numValidMergeCand = 0 ;
3017 for (
Int iPartIdx = 0; iPartIdx < iNumPart; iPartIdx++ )
3019 Distortion uiCost[2] = { std::numeric_limits<Distortion>::max(), std::numeric_limits<Distortion>::max() };
3020 Distortion uiCostBi = std::numeric_limits<Distortion>::max();
3025 Distortion bestBiPDist = std::numeric_limits<Distortion>::max();
3030 uiCostTempL0[iNumRef] = std::numeric_limits<Distortion>::max();
3035 Int refIdxValidList1 = 0;
3037 Distortion costValidList1 = std::numeric_limits<Distortion>::max();
3044 Bool bTestNormalMC =
true;
3046 if ( bUseMRG && pcCU->
getWidth( 0 ) > 8 && iNumPart == 2 )
3048 bTestNormalMC =
false;
3056 for (
Int iRefList = 0; iRefList < iNumPredDir; iRefList++ )
3062 uiBitsTemp = uiMbBits[iRefList];
3065 uiBitsTemp += iRefIdxTemp+1;
3071 xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp],
false, &biPDistTemp);
3072 aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->
getMVPIdx(eRefPicList, uiPartAddr);
3073 aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->
getMVPNum(eRefPicList, uiPartAddr);
3077 bestBiPDist = biPDistTemp;
3078 bestBiPMvpL1 = aaiMvpIdx[iRefList][iRefIdxTemp];
3079 bestBiPRefIdxL1 = iRefIdxTemp;
3100 xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
3105 xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
3108 xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
3110 if ( iRefList == 0 )
3112 uiCostTempL0[iRefIdxTemp] = uiCostTemp;
3113 uiBitsTempL0[iRefIdxTemp] = uiBitsTemp;
3115 if ( uiCostTemp < uiCost[iRefList] )
3117 uiCost[iRefList] = uiCostTemp;
3118 uiBits[iRefList] = uiBitsTemp;
3121 cMv[iRefList] = cMvTemp[iRefList][iRefIdxTemp];
3122 iRefIdx[iRefList] = iRefIdxTemp;
3125 if ( iRefList == 1 && uiCostTemp < costValidList1 && pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) < 0 )
3127 costValidList1 = uiCostTemp;
3128 bitsValidList1 = uiBitsTemp;
3131 mvValidList1 = cMvTemp[iRefList][iRefIdxTemp];
3132 refIdxValidList1 = iRefIdxTemp;
3141 cMvBi[0] = cMv[0]; cMvBi[1] = cMv[1];
3142 iRefIdxBi[0] = iRefIdx[0]; iRefIdxBi[1] = iRefIdx[1];
3144 ::memcpy(cMvPredBi, cMvPred,
sizeof(cMvPred));
3145 ::memcpy(aaiMvpIdxBi, aaiMvpIdx,
sizeof(aaiMvpIdx));
3153 aaiMvpIdxBi[1][bestBiPRefIdxL1] = bestBiPMvpL1;
3156 cMvBi[1] = cMvPredBi[1][bestBiPRefIdxL1];
3157 iRefIdxBi[1] = bestBiPRefIdxL1;
3163 uiMotBits[0] = uiBits[0] - uiMbBits[0];
3164 uiMotBits[1] = uiMbBits[1];
3168 uiMotBits[1] += bestBiPRefIdxL1+1;
3177 uiBits[2] = uiMbBits[2] + uiMotBits[0] + uiMotBits[1];
3179 cMvTemp[1][bestBiPRefIdxL1] = cMvBi[1];
3183 uiMotBits[0] = uiBits[0] - uiMbBits[0];
3184 uiMotBits[1] = uiBits[1] - uiMbBits[1];
3185 uiBits[2] = uiMbBits[2] + uiMotBits[0] + uiMotBits[1];
3197 for (
Int iIter = 0; iIter < iNumIter; iIter++ )
3199 Int iRefList = iIter % 2;
3203 if( uiCost[0] <= uiCost[1] )
3212 else if ( iIter == 0 )
3232 Bool bChanged =
false;
3237 for (
Int iRefIdxTemp = iRefStart; iRefIdxTemp <= iRefEnd; iRefIdxTemp++ )
3239 uiBitsTemp = uiMbBits[2] + uiMotBits[1-iRefList];
3242 uiBitsTemp += iRefIdxTemp+1;
3250 xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPredBi[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp,
true );
3253 xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPredBi[iRefList][iRefIdxTemp], aaiMvpIdxBi[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
3255 if ( uiCostTemp < uiCostBi )
3259 cMvBi[iRefList] = cMvTemp[iRefList][iRefIdxTemp];
3260 iRefIdxBi[iRefList] = iRefIdxTemp;
3262 uiCostBi = uiCostTemp;
3263 uiMotBits[iRefList] = uiBitsTemp - uiMbBits[2] - uiMotBits[1-iRefList];
3264 uiBits[2] = uiBitsTemp;
3269 pcCU->
getCUMvField( eRefPicList )->
setAllMv( cMvBi[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
3280 if ( uiCostBi <= uiCost[0] && uiCostBi <= uiCost[1] )
3311 cMv[1] = mvValidList1;
3312 iRefIdx[1] = refIdxValidList1;
3313 uiBits[1] = bitsValidList1;
3314 uiCost[1] = costValidList1;
3320 if ( uiCostBi <= uiCost[0] && uiCostBi <= uiCost[1])
3328 TempMv = cMvBi[0] - cMvPredBi[0][iRefIdxBi[0]];
3331 TempMv = cMvBi[1] - cMvPredBi[1][iRefIdxBi[1]];
3341 uiMEBits = uiBits[2];
3343 else if ( uiCost[0] <= uiCost[1] )
3349 TempMv = cMv[0] - cMvPred[0][iRefIdx[0]];
3357 uiMEBits = uiBits[0];
3365 TempMv = cMv[1] - cMvPred[1][iRefIdx[1]];
3373 uiMEBits = uiBits[1];
3381 UInt uiMRGInterDir = 0;
3383 UInt uiMRGIndex = 0;
3385 UInt uiMEInterDir = 0;
3392 Distortion uiMEError = std::numeric_limits<Distortion>::max();
3393 Distortion uiMECost = std::numeric_limits<Distortion>::max();
3402 Distortion uiMEError = std::numeric_limits<Distortion>::max();
3412 Distortion uiMRGCost = std::numeric_limits<Distortion>::max();
3414 xMergeEstimation( pcCU, pcOrgYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
3416 if ( uiMRGCost < uiMECost )
3471 Distortion uiBestCost = std::numeric_limits<Distortion>::max();
3472 UInt uiPartAddr = 0;
3473 Int iRoiWidth, iRoiHeight;
3482 pcCU->
fillMvpCand( uiPartIdx, uiPartAddr, eRefPicList, iRefIdx, pcAMVPInfo );
3498 maxMVPCand = pcAMVPInfo->
iN;
3504 maxMVPCand = pcAMVPInfo->
iN;
3506 if (pcAMVPInfo->
iN <= 1)
3515 (*puiDistBiP) =
xGetTemplateCost( pcCU, uiPartAddr, pcOrgYuv, &
m_cYuvPredTemp, rcMvPred, 0,
AMVP_MAX_NUM_CANDS, eRefPicList, iRefIdx, iRoiWidth, iRoiHeight);
3522 assert(pcCU->
getMVPIdx(eRefPicList,uiPartAddr) >= 0);
3529 for ( i = minMVPCand ; i < maxMVPCand; i++)
3532 uiTmpCost =
xGetTemplateCost( pcCU, uiPartAddr, pcOrgYuv, &
m_cYuvPredTemp, pcAMVPInfo->
m_acMvCand[i], i,
AMVP_MAX_NUM_CANDS, eRefPicList, iRefIdx, iRoiWidth, iRoiHeight);
3533 if ( uiBestCost > uiTmpCost )
3535 uiBestCost = uiTmpCost;
3538 (*puiDistBiP) = uiTmpCost;
3553 assert(iIdx >= 0 && iNum >= 0 && iIdx < iNum);
3567 Bool bCodeLast = ( iNum-1 > iTemp );
3569 uiLength += (iTemp-1);
3583 uiBlkBit[0] = (! bPSlice) ? 3 : 1;
3589 UInt aauiMbBits[2][3][3] = { { {0,0,3}, {0,0,0}, {0,0,0} } , { {5,7,7}, {7,5,7}, {9-3,9-3,9-3} } };
3598 ::memcpy( uiBlkBit, aauiMbBits[iPartIdx][uiLastMode], 3*
sizeof(
UInt) );
3603 UInt aauiMbBits[2][3][3] = { { {0,2,3}, {0,0,0}, {0,0,0} } , { {5,7,7}, {7-2,7-2,9-2}, {9-3,9-3,9-3} } };
3612 ::memcpy( uiBlkBit, aauiMbBits[iPartIdx][uiLastMode], 3*
sizeof(
UInt) );
3617 uiBlkBit[0] = (! bPSlice) ? 3 : 1;
3630 pDst->
iN = pSrc->
iN;
3631 for (
Int i = 0; i < pSrc->
iN; i++)
3641 assert(pcAMVPInfo->
m_acMvCand[riMVPIdx] == rcMvPred);
3643 if (pcAMVPInfo->
iN < 2)
3651 Int iBestMVPIdx = riMVPIdx;
3656 Int iBestMvBits = iOrgMvBits;
3660 Int maxMVPCand = pcAMVPInfo->
iN;
3667 for (
Int iMVPIdx = minMVPCand; iMVPIdx < maxMVPCand; iMVPIdx++)
3669 for (
Int iMVPIdx = 0; iMVPIdx < pcAMVPInfo->
iN; iMVPIdx++)
3672 if (iMVPIdx == riMVPIdx)
3682 if (iMvBits < iBestMvBits)
3684 iBestMvBits = iMvBits;
3685 iBestMVPIdx = iMVPIdx;
3689 if (iBestMVPIdx != riMVPIdx)
3691 rcMvPred = pcAMVPInfo->
m_acMvCand[iBestMVPIdx];
3693 riMVPIdx = iBestMVPIdx;
3694 UInt uiOrgBits = ruiBits;
3695 ruiBits = uiOrgBits - iOrgMvBits + iBestMvBits;
3714 Distortion uiCost = std::numeric_limits<Distortion>::max();
3732 xWeightedPredictionUni( pcCU, pcTemplateCand, uiPartAddr, iSizeX, iSizeY, eRefPicList, pcTemplateCand, iRefIdx );
3737 uiCost =
m_pcRdCost->
getDistPart( pcCU->
getSlice()->
getSPS()->
getBitDepth(
CHANNEL_TYPE_LUMA), pcTemplateCand->
getAddr(
COMPONENT_Y, uiPartAddr), pcTemplateCand->
getStride(
COMPONENT_Y), pcOrgYuv->
getAddr(
COMPONENT_Y, uiPartAddr), pcOrgYuv->
getStride(
COMPONENT_Y), iSizeX, iSizeY,
COMPONENT_Y,
DF_SAD );
3780 Int roiPosX, roiPosY;
3783 assert(roiW == iRoiWidth);
3784 assert(roiH == iRoiHeight);
3804 TComMv cMvPred = *pcMvPred;
3809 xSetSearchRange(pcCU, rcMv, iSrchRng, cMvSrchRngLT, cMvSrchRngRB, &cPattern);
3817 xSetSearchRange(pcCU, cMvPred, iSrchRng, cMvSrchRngLT, cMvSrchRngRB, &cPattern);
3832 xPatternSearch ( &cPattern, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost );
3837 const TComMv *pIntegerMv2Nx2NPred=0;
3842 xPatternSearchFast ( pcCU, &cPattern, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost, pIntegerMv2Nx2NPred );
3853 xPatternSearchFracDIF( bIsLosslessCoded, &cPattern, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost );
3857 rcMv += (cMvHalf <<= 1);
3862 ruiBits += uiMvBits;
3871 UInt tileXPosInCtus = 0;
3872 UInt tileYPosInCtus = 0;
3873 UInt tileWidthtInCtus = 0;
3874 UInt tileHeightInCtus = 0;
3876 getTilePosition(pcCU, tileXPosInCtus, tileYPosInCtus, tileWidthtInCtus, tileHeightInCtus);
3881 const Int tileLeftTopPelPosX = ctuLength * tileXPosInCtus;
3882 const Int tileLeftTopPelPosY = ctuLength * tileYPosInCtus;
3883 const Int tileRightBottomPelPosX = ((tileWidthtInCtus + tileXPosInCtus) * ctuLength) - 1;
3884 const Int tileRightBottomPelPosY = ((tileHeightInCtus + tileYPosInCtus) * ctuLength) - 1;
3886 pcPatternKey->
setTileBorders (tileLeftTopPelPosX,tileLeftTopPelPosY,tileRightBottomPelPosX,tileRightBottomPelPosY);
3900 TComMv cTmpMvPred = cMvPred;
3901 pcCU->
clipMv( cTmpMvPred );
3911 rcMvSrchRngLT.setHor(lRangeXLeft);
3912 rcMvSrchRngLT.setVer(lRangeYTop);
3914 rcMvSrchRngRB.
setHor(lRangeXRight);
3915 rcMvSrchRngRB.
setVer(lRangeYBottom);
3919 rcMvSrchRngLT.setHor(cTmpMvPred.
getHor() - (iSrchRng << iMvShift));
3920 rcMvSrchRngLT.setVer(cTmpMvPred.
getVer() - (iSrchRng << iMvShift));
3922 rcMvSrchRngRB.
setHor( cTmpMvPred.
getHor() + (iSrchRng << iMvShift));
3923 rcMvSrchRngRB.
setVer( cTmpMvPred.
getVer() + (iSrchRng << iMvShift) );
3926 rcMvSrchRngLT.setHor( cTmpMvPred.
getHor() - (iSrchRng << iMvShift) );
3927 rcMvSrchRngLT.setVer( cTmpMvPred.
getVer() - (iSrchRng << iMvShift) );
3929 rcMvSrchRngRB.
setHor( cTmpMvPred.
getHor() + (iSrchRng << iMvShift));
3930 rcMvSrchRngRB.
setVer( cTmpMvPred.
getVer() + (iSrchRng << iMvShift) );
3933 pcCU->
clipMv ( rcMvSrchRngLT );
3934 pcCU->
clipMv ( rcMvSrchRngRB );
3936 #if ME_ENABLE_ROUNDING_OF_MVS
3937 rcMvSrchRngLT.divideByPowerOf2(iMvShift);
3940 rcMvSrchRngLT >>= iMvShift;
3941 rcMvSrchRngRB >>= iMvShift;
3948 const Int iRefStride,
3949 const TComMv*
const pcMvSrchRngLT,
3950 const TComMv*
const pcMvSrchRngRB,
3954 Int iSrchRngHorLeft = pcMvSrchRngLT->
getHor();
3955 Int iSrchRngHorRight = pcMvSrchRngRB->
getHor();
3956 Int iSrchRngVerTop = pcMvSrchRngLT->
getVer();
3957 Int iSrchRngVerBottom = pcMvSrchRngRB->
getVer();
3960 Distortion uiSadBest = std::numeric_limits<Distortion>::max();
3976 piRefY += (iSrchRngVerTop * iRefStride);
3977 for (
Int y = iSrchRngVerTop; y <= iSrchRngVerBottom; y++ )
3979 for (
Int x = iSrchRngHorLeft; x <= iSrchRngHorRight; x++ )
3992 if ( uiSad < uiSadBest )
4000 piRefY += iRefStride;
4003 rcMv.
set( iBestX, iBestY );
4012 const Pel*
const piRefY,
4013 const Int iRefStride,
4014 const TComMv*
const pcMvSrchRngLT,
4015 const TComMv*
const pcMvSrchRngRB,
4018 const TComMv*
const pIntegerMv2Nx2NPred )
4030 xTZSearch( pcCU, pcPatternKey, piRefY, iRefStride, pcMvSrchRngLT, pcMvSrchRngRB, rcMv, ruiSAD, pIntegerMv2Nx2NPred,
false );
4034 xTZSearchSelective( pcCU, pcPatternKey, piRefY, iRefStride, pcMvSrchRngLT, pcMvSrchRngRB, rcMv, ruiSAD, pIntegerMv2Nx2NPred );
4038 xTZSearch( pcCU, pcPatternKey, piRefY, iRefStride, pcMvSrchRngLT, pcMvSrchRngRB, rcMv, ruiSAD, pIntegerMv2Nx2NPred,
true );
4050 const Pel*
const piRefY,
4051 const Int iRefStride,
4052 const TComMv*
const pcMvSrchRngLT,
4053 const TComMv*
const pcMvSrchRngRB,
4056 const TComMv*
const pIntegerMv2Nx2NPred,
4057 const Bool bExtendedSettings)
4059 const Bool bUseAdaptiveRaster = bExtendedSettings;
4060 const Int iRaster = 5;
4061 const Bool bTestOtherPredictedMV = bExtendedSettings;
4062 const Bool bTestZeroVector =
true;
4063 const Bool bTestZeroVectorStart = bExtendedSettings;
4064 const Bool bTestZeroVectorStop =
false;
4065 const Bool bFirstSearchDiamond =
true;
4066 const Bool bFirstCornersForDiamondDist1 = bExtendedSettings;
4068 const UInt uiFirstSearchRounds = 3;
4069 const Bool bEnableRasterSearch =
true;
4070 const Bool bAlwaysRasterSearch = bExtendedSettings;
4071 const Bool bRasterRefinementEnable =
false;
4072 const Bool bRasterRefinementDiamond =
false;
4073 const Bool bRasterRefinementCornersForDiamondDist1 = bExtendedSettings;
4074 const Bool bStarRefinementEnable =
true;
4075 const Bool bStarRefinementDiamond =
true;
4076 const Bool bStarRefinementCornersForDiamondDist1 = bExtendedSettings;
4077 const Bool bStarRefinementStop =
false;
4078 const UInt uiStarRefinementRounds = 2;
4079 const Bool bNewZeroNeighbourhoodTest = bExtendedSettings;
4083 #if ME_ENABLE_ROUNDING_OF_MVS
4098 if ( bTestOtherPredictedMV )
4104 #if ME_ENABLE_ROUNDING_OF_MVS
4118 if ( bTestZeroVector )
4128 Int iSrchRngHorLeft = pcMvSrchRngLT->
getHor();
4129 Int iSrchRngHorRight = pcMvSrchRngRB->
getHor();
4130 Int iSrchRngVerTop = pcMvSrchRngLT->
getVer();
4131 Int iSrchRngVerBottom = pcMvSrchRngRB->
getVer();
4133 if (pIntegerMv2Nx2NPred != 0)
4135 TComMv integerMv2Nx2NPred = *pIntegerMv2Nx2NPred;
4136 integerMv2Nx2NPred <<= 2;
4137 pcCU->
clipMv( integerMv2Nx2NPred );
4138 #if ME_ENABLE_ROUNDING_OF_MVS
4141 integerMv2Nx2NPred >>= 2;
4143 if ((rcMv != integerMv2Nx2NPred) &&
4157 xSetSearchRange(pcCU, currBestMv, iSrchRng, cMvSrchRngLT, cMvSrchRngRB, pcPatternKey);
4159 xSetSearchRange(pcCU, currBestMv, iSrchRng, cMvSrchRngLT, cMvSrchRngRB);
4161 iSrchRngHorLeft = cMvSrchRngLT.
getHor();
4162 iSrchRngHorRight = cMvSrchRngRB.
getHor();
4163 iSrchRngVerTop = cMvSrchRngLT.
getVer();
4164 iSrchRngVerBottom = cMvSrchRngRB.
getVer();
4172 const Bool bBestCandidateZero = (cStruct.
iBestX == 0) && (cStruct.
iBestY == 0);
4176 for ( iDist = 1; iDist <= (
Int)uiSearchRange; iDist*=2 )
4178 if ( bFirstSearchDiamond == 1 )
4180 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist, bFirstCornersForDiamondDist1 );
4184 xTZ8PointSquareSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist );
4187 if ( bFirstSearchStop && ( cStruct.
uiBestRound >= uiFirstSearchRounds ) )
4193 if (!bNewZeroNeighbourhoodTest)
4196 if ( bTestZeroVectorStart && ((cStruct.
iBestX != 0) || (cStruct.
iBestY != 0)) )
4202 for ( iDist = 1; iDist <= (
Int)uiSearchRange; iDist*=2 )
4205 if ( bTestZeroVectorStop && (cStruct.
uiBestRound > 0) )
4219 if (bTestZeroVectorStart ==
true && bBestCandidateZero !=
true)
4221 for ( iDist = 1; iDist <= ((Int)uiSearchRange >> 1); iDist*=2 )
4224 if ( bTestZeroVectorStop && (cStruct.
uiBestRound > 2) )
4236 xTZ2PointSearch( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB );
4240 if (bUseAdaptiveRaster)
4242 Int iWindowSize = iRaster;
4243 Int iSrchRngRasterLeft = iSrchRngHorLeft;
4244 Int iSrchRngRasterRight = iSrchRngHorRight;
4245 Int iSrchRngRasterTop = iSrchRngVerTop;
4246 Int iSrchRngRasterBottom = iSrchRngVerBottom;
4251 iSrchRngRasterLeft /= 2;
4252 iSrchRngRasterRight /= 2;
4253 iSrchRngRasterTop /= 2;
4254 iSrchRngRasterBottom /= 2;
4257 for ( iStartY = iSrchRngRasterTop; iStartY <= iSrchRngRasterBottom; iStartY += iWindowSize )
4259 for ( iStartX = iSrchRngRasterLeft; iStartX <= iSrchRngRasterRight; iStartX += iWindowSize )
4261 xTZSearchHelp( pcPatternKey, cStruct, iStartX, iStartY, 0, iWindowSize );
4267 if ( bEnableRasterSearch && ( ((
Int)(cStruct.
uiBestDistance) > iRaster) || bAlwaysRasterSearch ) )
4270 for ( iStartY = iSrchRngVerTop; iStartY <= iSrchRngVerBottom; iStartY += iRaster )
4272 for ( iStartX = iSrchRngHorLeft; iStartX <= iSrchRngHorRight; iStartX += iRaster )
4274 xTZSearchHelp( pcPatternKey, cStruct, iStartX, iStartY, 0, iRaster );
4286 iStartX = cStruct.
iBestX;
4287 iStartY = cStruct.
iBestY;
4291 if ( bRasterRefinementDiamond == 1 )
4293 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist, bRasterRefinementCornersForDiamondDist1 );
4297 xTZ8PointSquareSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist );
4307 xTZ2PointSearch( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB );
4318 iStartX = cStruct.
iBestX;
4319 iStartY = cStruct.
iBestY;
4322 for ( iDist = 1; iDist < (
Int)uiSearchRange + 1; iDist*=2 )
4324 if ( bStarRefinementDiamond == 1 )
4326 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist, bStarRefinementCornersForDiamondDist1 );
4330 xTZ8PointSquareSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist );
4332 if ( bStarRefinementStop && (cStruct.
uiBestRound >= uiStarRefinementRounds) )
4344 xTZ2PointSearch( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB );
4358 const Pel*
const piRefY,
4359 const Int iRefStride,
4360 const TComMv*
const pcMvSrchRngLT,
4361 const TComMv*
const pcMvSrchRngRB,
4364 const TComMv*
const pIntegerMv2Nx2NPred )
4366 const Bool bTestOtherPredictedMV =
true;
4367 const Bool bTestZeroVector =
true;
4368 const Bool bEnableRasterSearch =
true;
4369 const Bool bAlwaysRasterSearch =
false;
4370 const Bool bStarRefinementEnable =
true;
4371 const Bool bStarRefinementDiamond =
true;
4372 const Bool bStarRefinementStop =
false;
4373 const UInt uiStarRefinementRounds = 2;
4376 const Int uiSearchStep = 4;
4377 const Int iMVDistThresh = 8;
4379 Int iSrchRngHorLeft = pcMvSrchRngLT->
getHor();
4380 Int iSrchRngHorRight = pcMvSrchRngRB->
getHor();
4381 Int iSrchRngVerTop = pcMvSrchRngLT->
getVer();
4382 Int iSrchRngVerBottom = pcMvSrchRngRB->
getVer();
4383 Int iFirstSrchRngHorLeft = 0;
4384 Int iFirstSrchRngHorRight = 0;
4385 Int iFirstSrchRngVerTop = 0;
4386 Int iFirstSrchRngVerBottom = 0;
4394 #if ME_ENABLE_ROUNDING_OF_MVS
4412 if ( bTestOtherPredictedMV )
4418 #if ME_ENABLE_ROUNDING_OF_MVS
4428 if ( bTestZeroVector )
4433 if ( pIntegerMv2Nx2NPred != 0 )
4435 TComMv integerMv2Nx2NPred = *pIntegerMv2Nx2NPred;
4436 integerMv2Nx2NPred <<= 2;
4437 pcCU->
clipMv( integerMv2Nx2NPred );
4438 #if ME_ENABLE_ROUNDING_OF_MVS
4441 integerMv2Nx2NPred >>= 2;
4452 xSetSearchRange(pcCU, currBestMv, iSrchRng, cMvSrchRngLT, cMvSrchRngRB, pcPatternKey);
4454 xSetSearchRange(pcCU, currBestMv, iSrchRng, cMvSrchRngLT, cMvSrchRngRB);
4456 iSrchRngHorLeft = cMvSrchRngLT.getHor();
4457 iSrchRngHorRight = cMvSrchRngRB.
getHor();
4458 iSrchRngVerTop = cMvSrchRngLT.getVer();
4459 iSrchRngVerBottom = cMvSrchRngRB.
getVer();
4465 iFirstSrchRngHorLeft = ((iBestX - uiSearchRangeInitial) > iSrchRngHorLeft) ? (iBestX - uiSearchRangeInitial) : iSrchRngHorLeft;
4466 iFirstSrchRngVerTop = ((iBestY - uiSearchRangeInitial) > iSrchRngVerTop) ? (iBestY - uiSearchRangeInitial) : iSrchRngVerTop;
4467 iFirstSrchRngHorRight = ((iBestX + uiSearchRangeInitial) < iSrchRngHorRight) ? (iBestX + uiSearchRangeInitial) : iSrchRngHorRight;
4468 iFirstSrchRngVerBottom = ((iBestY + uiSearchRangeInitial) < iSrchRngVerBottom) ? (iBestY + uiSearchRangeInitial) : iSrchRngVerBottom;
4470 for ( iStartY = iFirstSrchRngVerTop; iStartY <= iFirstSrchRngVerBottom; iStartY += uiSearchStep )
4472 for ( iStartX = iFirstSrchRngHorLeft; iStartX <= iFirstSrchRngHorRight; iStartX += uiSearchStep )
4474 xTZSearchHelp( pcPatternKey, cStruct, iStartX, iStartY, 0, 0 );
4475 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, 1,
false );
4476 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, 2,
false );
4480 Int iMaxMVDistToPred = (abs(cStruct.
iBestX - iBestX) > iMVDistThresh || abs(cStruct.
iBestY - iBestY) > iMVDistThresh);
4483 if ( bEnableRasterSearch && (iMaxMVDistToPred || bAlwaysRasterSearch) )
4485 for ( iStartY = iSrchRngVerTop; iStartY <= iSrchRngVerBottom; iStartY += 1 )
4487 for ( iStartX = iSrchRngHorLeft; iStartX <= iSrchRngHorRight; iStartX += 1 )
4489 xTZSearchHelp( pcPatternKey, cStruct, iStartX, iStartY, 0, 1 );
4499 iStartX = cStruct.
iBestX;
4500 iStartY = cStruct.
iBestY;
4503 for ( iDist = 1; iDist < (
Int)uiSearchRange + 1; iDist*=2 )
4505 if ( bStarRefinementDiamond == 1 )
4507 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist,
false );
4511 xTZ8PointSquareSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist );
4513 if ( bStarRefinementStop && (cStruct.
uiBestRound >= uiStarRefinementRounds) )
4525 xTZ2PointSearch( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB );
4539 Bool bIsLosslessCoded,
4570 rcMvHalf = *pcMvInt; rcMvHalf <<= 1;
4572 ruiCost =
xPatternRefinement( pcPatternKey, baseRefMv, 2, rcMvHalf, !bIsLosslessCoded );
4577 baseRefMv = rcMvHalf;
4580 rcMvQter = *pcMvInt; rcMvQter <<= 1;
4581 rcMvQter += rcMvHalf; rcMvQter <<= 1;
4582 ruiCost =
xPatternRefinement( pcPatternKey, baseRefMv, 1, rcMvQter, !bIsLosslessCoded );
4601 if ( bSkipResidual )
4610 for (
Int comp=0; comp < numValidComponents; comp++)
4616 pcYuvOrg->
getStride(compID), cuWidthPixels >> csx, cuHeightPixels >> csy, compID);
4638 pcYuvResiBest->
clear();
4641 sDebug+=debug_reorder_data_inter_token[i];
4650 pcYuvResi->
subtract( pcYuvOrg, pcYuvPred, 0, cuWidthPixels );
4655 UInt nonZeroBits = 0;
4673 if ( zeroCost < nonZeroCost || !pcCU->getQtRootCbf(0) )
4677 for (
Int comp=0; comp < numValidComponents; comp++)
4680 ::memset( pcCU->
getCbf( component ) , 0, uiQPartNum *
sizeof(
UChar) );
4689 sDebug+=debug_reorder_data_inter_token[i];
4707 pcYuvResiBest->
clear();
4720 for(
Int comp=0; comp<numValidComponents; comp++)
4742 const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU();
4743 const UInt uiDepth = rTu.GetTransformDepthTotal();
4744 const UInt uiTrMode = rTu.GetTransformDepthRel();
4745 const UInt subTUDepth = uiTrMode + 1;
4750 const UInt uiLog2TrSize = rTu.GetLog2LumaTrSize();
4754 const Int debugPredModeMask = DebugStringGetPredModeMask(pcCU->
getPredictionMode(uiAbsPartIdx));
4770 assert( bCheckFull || bCheckSplit );
4774 UInt uiSingleBits = 0;
4797 #if ADAPTIVE_QP_SELECTION
4801 for(
UInt i=0; i<numValidComp; i++)
4809 for(
UInt i=0; i<numValidComp; i++)
4811 checkTransformSkip[i]=
false;
4814 pcCoeffCurr[compID] =
m_ppcQTTempCoeff[compID][uiQTTempAccessLayer] + rTu.getCoefficientOffset(compID);
4815 #if ADAPTIVE_QP_SELECTION
4816 pcArlCoeffCurr[compID] =
m_ppcQTTempArlCoeff[compID ][uiQTTempAccessLayer] + rTu.getCoefficientOffset(compID);
4819 if(rTu.ProcessComponentSection(compID))
4821 const QpParam cQP(*pcCU, compID);
4827 const Bool splitIntoSubTUs = rTu.getRect(compID).width != rTu.getRect(compID).height;
4838 const UInt subTUBufferOffset = tuCompRect.
width * tuCompRect.
height * subTUIndex;
4840 TCoeff *currentCoefficients = pcCoeffCurr[compID] + subTUBufferOffset;
4841 #if ADAPTIVE_QP_SELECTION
4842 TCoeff *currentARLCoefficients = pcArlCoeffCurr[compID] + subTUBufferOffset;
4844 const Bool isCrossCPredictionAvailable =
isChroma(compID)
4848 SChar preCalcAlpha = 0;
4851 if (isCrossCPredictionAvailable)
4854 const Pel *
const lumaResidualForEstimate = bUseReconstructedResidualForEstimate ? pLumaResi : pcResi->
getAddrPix(
COMPONENT_Y, tuCompRect.
x0, tuCompRect.
y0);
4859 lumaResidualForEstimate,
4863 lumaResidualStrideForEstimate,
4867 const Int transformSkipModesToTest = checkTransformSkip[compID] ? 2 : 1;
4868 const Int crossCPredictionModesToTest = (preCalcAlpha != 0) ? 2 : 1;
4870 const Bool isOneMode = (crossCPredictionModesToTest == 1) && (transformSkipModesToTest == 1);
4872 for (
Int transformSkipModeId = 0; transformSkipModeId < transformSkipModesToTest; transformSkipModeId++)
4876 for (
Int crossCPredictionModeId = 0; crossCPredictionModeId < crossCPredictionModesToTest; crossCPredictionModeId++)
4878 const Bool isFirstMode = (transformSkipModeId == 0) && (crossCPredictionModeId == 0);
4879 const Bool bUseCrossCPrediction = crossCPredictionModeId != 0;
4893 #if RDOQ_CHROMA_LAMBDA
4903 #if ADAPTIVE_QP_SELECTION
4907 UInt currCompBits = 0;
4910 UInt nonCoeffBits = 0;
4914 if(!isOneMode && !isFirstMode)
4916 memcpy(bestCoeffComp, currentCoefficients, (
sizeof(
TCoeff) * tuCompRect.
width * tuCompRect.
height));
4917 #if ADAPTIVE_QP_SELECTION
4918 memcpy(bestArlCoeffComp, currentARLCoefficients, (
sizeof(
TCoeff) * tuCompRect.
width * tuCompRect.
height));
4920 for(
Int y = 0; y < tuCompRect.
height; y++)
4922 memcpy(&bestResiComp[y * tuCompRect.
width], (pcResiCurrComp + (y * resiStride)), (
sizeof(
Pel) * tuCompRect.
width));
4926 if (bUseCrossCPrediction)
4932 crossCPredictedResidualBuffer,
4942 currentARLCoefficients,
4949 #if ADAPTIVE_QP_SELECTION
4950 currentARLCoefficients,
4955 if(isFirstMode || (currAbsSum == 0))
4957 if (bUseCrossCPrediction)
4983 if ( isCrossCPredictionAvailable )
4992 if((puiZeroDist !=
NULL) && isFirstMode)
4994 *puiZeroDist += nonCoeffDist;
4999 if( currAbsSum > 0 )
5009 if (isCrossCPredictionAvailable)
5021 if (bUseCrossCPrediction)
5049 else if ((transformSkipModeId == 1) && !bUseCrossCPrediction)
5055 currCompBits = nonCoeffBits;
5056 currCompDist = nonCoeffDist;
5057 currCompCost = nonCoeffCost;
5061 if ((currCompCost < minCost[compID][subTUIndex]) || ((transformSkipModeId == 1) && (currCompCost == minCost[compID][subTUIndex])))
5063 bestExplicitRdpcmModeUnSplit[compID][subTUIndex] = pcCU->
getExplicitRdpcmMode(compID, subTUAbsPartIdx);
5067 if((nonCoeffCost < currCompCost) || (currAbsSum == 0))
5069 memset(currentCoefficients, 0, (
sizeof(
TCoeff) * tuCompRect.
width * tuCompRect.
height));
5072 currCompBits = nonCoeffBits;
5073 currCompDist = nonCoeffDist;
5074 currCompCost = nonCoeffCost;
5085 sSingleStringComp[compID].clear();
5089 uiAbsSum [compID][subTUIndex] = currAbsSum;
5090 uiSingleDistComp [compID][subTUIndex] = currCompDist;
5091 minCost [compID][subTUIndex] = currCompCost;
5092 uiBestTransformMode [compID][subTUIndex] = transformSkipModeId;
5095 if (uiAbsSum[compID][subTUIndex] == 0)
5097 if (bUseCrossCPrediction)
5115 for(
UInt uiY = 0; uiY < tuCompRect.
height; uiY++)
5117 memset(pcResiCurrComp, 0, (
sizeof(
Pel) * tuCompRect.
width));
5118 pcResiCurrComp += uiStride;
5126 memcpy(currentCoefficients, bestCoeffComp, (
sizeof(
TCoeff) * tuCompRect.
width * tuCompRect.
height));
5127 #if ADAPTIVE_QP_SELECTION
5128 memcpy(currentARLCoefficients, bestArlCoeffComp, (
sizeof(
TCoeff) * tuCompRect.
width * tuCompRect.
height));
5130 for (
Int y = 0; y < tuCompRect.
height; y++)
5132 memcpy((pcResiCurrComp + (y * resiStride)), &bestResiComp[y * tuCompRect.
width], (
sizeof(
Pel) * tuCompRect.
width));
5139 pcCU->
setTransformSkipPartRange ( uiBestTransformMode [compID][subTUIndex], compID, subTUAbsPartIdx, partIdxesPerSubTU );
5140 pcCU->
setCbfPartRange ((((uiAbsSum [compID][subTUIndex] > 0) ? 1 : 0) << uiTrMode), compID, subTUAbsPartIdx, partIdxesPerSubTU );
5146 for(
UInt ch = 0; ch < numValidComp; ch++)
5149 if (rTu.ProcessComponentSection(compID) && (rTu.getRect(compID).width != rTu.getRect(compID).height))
5163 for(
UInt ch = 0; ch < numValidComp; ch++)
5165 const UInt chOrderChange = ((ch + 1) == numValidComp) ? 0 : (ch + 1);
5167 if( rTu.ProcessComponentSection(compID) )
5173 for(
UInt ch = 0; ch < numValidComp; ch++)
5176 if (rTu.ProcessComponentSection(compID))
5184 for (
UInt subTUIndex = 0; subTUIndex < 2; subTUIndex++)
5186 uiSingleDist += uiSingleDistComp[compID][subTUIndex];
5205 UInt uiSubdivBits = 0;
5206 Double dSubdivCost = 0.0;
5212 for(
UInt ch = 0; ch < numValidComp; ch++)
5216 if (rTu.ProcessComponentSection(compID))
5218 bestCBF[compID] = pcCU->
getCbf(uiAbsPartIdx, compID, uiTrMode);
5223 const UInt partIdxesPerSubTU = rTu.GetAbsPartIdxNumParts(compID) >> 1;
5225 for (
UInt subTU = 0; subTU < 2; subTU++)
5227 bestsubTUCBF[compID][subTU] = pcCU->
getCbf ((uiAbsPartIdx + (subTU * partIdxesPerSubTU)), compID, subTUDepth);
5245 std::size_t lastPos=0;
5246 const std::size_t endStrng=childString.find(debug_reorder_data_inter_token[MAX_NUM_COMPONENT], lastPos);
5247 for(
UInt ch = 0; ch < numValidComp; ch++)
5249 if (lastPos!=std::string::npos && childString.find(debug_reorder_data_inter_token[ch], lastPos)==lastPos)
5251 lastPos+=strlen(debug_reorder_data_inter_token[ch]);
5253 std::size_t pos=childString.find(debug_reorder_data_inter_token[ch+1], lastPos);
5254 if (pos!=std::string::npos && pos>endStrng)
5258 sSplitString[ch]+=childString.substr(lastPos, (pos==std::string::npos)? std::string::npos : (pos-lastPos) );
5265 for(
UInt ch = 0; ch < numValidComp; ch++)
5268 for(
UInt ui = 0; ui < 4; ++ui )
5270 uiYUVCbf |= pcCU->
getCbf( uiAbsPartIdx + ui * uiQPartNumSubdiv,
ComponentID(ch), uiTrMode + 1 );
5273 const UInt flags=uiYUVCbf << uiTrMode;
5274 for(
UInt ui = 0; ui < 4 * uiQPartNumSubdiv; ++ui )
5276 pBase[uiAbsPartIdx + ui] |= flags;
5286 for(
UInt ch = 0; ch < numValidComp; ch++)
5294 if (!bCheckFull || (uiCbfAny && (dSubdivCost < dSingleCost)))
5296 rdCost += dSubdivCost;
5297 ruiBits += uiSubdivBits;
5298 ruiDist += uiSubdivDist;
5300 for(
UInt ch = 0; ch < numValidComp; ch++)
5309 rdCost += dSingleCost;
5310 ruiBits += uiSingleBits;
5311 ruiDist += uiSingleDist;
5317 for(
UInt ch = 0; ch < numValidComp; ch++)
5322 if (rTu.ProcessComponentSection(compID))
5326 const Bool splitIntoSubTUs = rTu.getRect(compID).width != rTu.getRect(compID).height;
5327 const UInt numberOfSections = splitIntoSubTUs ? 2 : 1;
5328 const UInt partIdxesPerSubTU = rTu.GetAbsPartIdxNumParts(compID) >> (splitIntoSubTUs ? 1 : 0);
5330 for (
UInt subTUIndex = 0; subTUIndex < numberOfSections; subTUIndex++)
5332 const UInt uisubTUPartIdx = uiAbsPartIdx + (subTUIndex * partIdxesPerSubTU);
5334 if (splitIntoSubTUs)
5336 const UChar combinedCBF = (bestsubTUCBF[compID][subTUIndex] << subTUDepth) | (bestCBF[compID] << uiTrMode);
5337 pcCU->
setCbfPartRange(combinedCBF, compID, uisubTUPartIdx, partIdxesPerSubTU);
5341 pcCU->
setCbfPartRange((bestCBF[compID] << uiTrMode), compID, uisubTUPartIdx, partIdxesPerSubTU);
5356 rdCost += dSingleCost;
5357 ruiBits += uiSingleBits;
5358 ruiDist += uiSingleDist;
5360 for(
UInt ch = 0; ch < numValidComp; ch++)
5365 if (rTu.ProcessComponentSection(compID))
5385 const Bool bSubdiv = uiCurrTrMode != uiTrMode;
5391 if( uiLog2TrSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() && uiLog2TrSize > pcCU->
getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) )
5403 assert( !pcCU->
isIntra(uiAbsPartIdx) );
5405 const Bool bFirstCbfOfCU = uiCurrTrMode == 0;
5412 if( bFirstCbfOfCU || pcCU->
getCbf( uiAbsPartIdx, compIdInner, uiCurrTrMode - 1 ) )
5419 assert( pcCU->
getCbf( uiAbsPartIdx, compIdInner, uiCurrTrMode ) == pcCU->
getCbf( uiAbsPartIdx, compIdInner, uiCurrTrMode - 1 ) );
5440 if (pcCU->
getCbf(uiAbsPartIdx, compID, uiTrMode) != 0)
5474 if( uiCurrTrMode == uiTrMode )
5501 const UInt numCoeffInBlock = rectCompTU.
width * rectCompTU.height;
5505 ::memcpy( dest, src,
sizeof(
TCoeff)*numCoeffInBlock );
5507 #if ADAPTIVE_QP_SELECTION
5510 ::memcpy( pcArlCoeffDst, pcArlCoeffSrc,
sizeof(
TCoeff ) * numCoeffInBlock );
5540 UChar origVal=rIntraDirVal;
5541 rIntraDirVal = uiMode;
5554 rIntraDirVal = origVal;
5567 while ( shift<uiFastCandNum && uiCost<CandCostList[ uiFastCandNum-1-shift ] )
5574 for(i=1; i<shift; i++)
5576 CandModeList[ uiFastCandNum-i ] = CandModeList[ uiFastCandNum-1-i ];
5577 CandCostList[ uiFastCandNum-i ] = CandCostList[ uiFastCandNum-1-i ];
5579 CandModeList[ uiFastCandNum-shift ] = uiMode;
5580 CandCostList[ uiFastCandNum-shift ] = uiCost;
5628 Bool codeDeltaQp =
false;
5629 Bool codeChromaQpAdj =
false;
5657 Int halfFilterSize = (filterSize>>1);
5658 Pel *srcPtr = pattern->
getROIY() - halfFilterSize*srcStride - 1;
5662 m_if.
filterHor(
COMPONENT_Y, srcPtr, srcStride,
m_filteredBlockTmp[0].getAddr(
COMPONENT_Y), intStride, width+1, height+filterSize, 0,
false, chFmt, pattern->
getBitDepthY());
5663 m_if.
filterHor(
COMPONENT_Y, srcPtr, srcStride,
m_filteredBlockTmp[2].getAddr(
COMPONENT_Y), intStride, width+1, height+filterSize, 2,
false, chFmt, pattern->
getBitDepthY());
5667 m_if.
filterVer(
COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width+0, height+0, 0,
false,
true, chFmt, pattern->
getBitDepthY());
5671 m_if.
filterVer(
COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width+0, height+1, 2,
false,
true, chFmt, pattern->
getBitDepthY());
5675 m_if.
filterVer(
COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width+1, height+0, 0,
false,
true, chFmt, pattern->
getBitDepthY());
5679 m_if.
filterVer(
COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width+1, height+1, 2,
false,
true, chFmt, pattern->
getBitDepthY());
5706 Int halfFilterSize = (filterSize>>1);
5708 Int extHeight = (halfPelRef.
getVer() == 0) ? height + filterSize : height + filterSize-1;
5713 srcPtr = pattern->
getROIY() - halfFilterSize * srcStride - 1;
5715 if (halfPelRef.
getVer() > 0)
5717 srcPtr += srcStride;
5719 if (halfPelRef.
getHor() >= 0)
5723 m_if.
filterHor(
COMPONENT_Y, srcPtr, srcStride, intPtr, intStride, width, extHeight, 1,
false, chFmt, pattern->
getBitDepthY());
5726 srcPtr = pattern->
getROIY() - halfFilterSize*srcStride - 1;
5728 if (halfPelRef.
getVer() > 0)
5730 srcPtr += srcStride;
5732 if (halfPelRef.
getHor() > 0)
5736 m_if.
filterHor(
COMPONENT_Y, srcPtr, srcStride, intPtr, intStride, width, extHeight, 3,
false, chFmt, pattern->
getBitDepthY());
5741 if (halfPelRef.
getVer() == 0)
5743 intPtr += intStride;
5745 m_if.
filterVer(
COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 1,
false,
true, chFmt, pattern->
getBitDepthY());
5750 m_if.
filterVer(
COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 3,
false,
true, chFmt, pattern->
getBitDepthY());
5752 if (halfPelRef.
getVer() != 0)
5757 if (halfPelRef.
getVer() == 0)
5759 intPtr += intStride;
5761 m_if.
filterVer(
COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 2,
false,
true, chFmt, pattern->
getBitDepthY());
5766 if (halfPelRef.
getVer() == 0)
5768 intPtr += intStride;
5770 m_if.
filterVer(
COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 2,
false,
true, chFmt, pattern->
getBitDepthY());
5777 m_if.
filterVer(
COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 0,
false,
true, chFmt, pattern->
getBitDepthY());
5782 m_if.
filterVer(
COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 0,
false,
true, chFmt, pattern->
getBitDepthY());
5785 if (halfPelRef.
getHor() != 0)
5790 if (halfPelRef.
getHor() > 0)
5794 if (halfPelRef.
getVer() >= 0)
5796 intPtr += intStride;
5798 m_if.
filterVer(
COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 1,
false,
true, chFmt, pattern->
getBitDepthY());
5803 if (halfPelRef.
getHor() > 0)
5807 if (halfPelRef.
getVer() > 0)
5809 intPtr += intStride;
5811 m_if.
filterVer(
COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 3,
false,
true, chFmt, pattern->
getBitDepthY());
5818 if (halfPelRef.
getVer() >= 0)
5820 intPtr += intStride;
5822 m_if.
filterVer(
COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 1,
false,
true, chFmt, pattern->
getBitDepthY());
5827 if (halfPelRef.
getVer() > 0)
5829 intPtr += intStride;
5831 m_if.
filterVer(
COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 3,
false,
true, chFmt, pattern->
getBitDepthY());
5837 if (halfPelRef.
getVer() == 0)
5839 intPtr += intStride;
5841 m_if.
filterVer(
COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 1,
false,
true, chFmt, pattern->
getBitDepthY());
5846 m_if.
filterVer(
COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 3,
false,
true, chFmt, pattern->
getBitDepthY());
Void xRestrictBipredMergeCand(TComDataCU *pcCU, UInt puIdx, TComMvField *mvFieldNeighbours, UChar *interDirNeighbours, Int numValidMergeCand)
UInt getQuadtreeTULog2MinSizeInCU(UInt uiIdx) const
Distortion getCost(UInt b)
UChar getNumPartitions(const UInt uiAbsPartIdx=0) const
Bool getCrossComponentPredictionEnabledFlag() const
Void setMVPNumSubParts(Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth)
Void destroy()
Destroy YUV buffer.
Int getMVPIdx(RefPicList eRefPicList, UInt uiIdx) const
Void xEncPCM(TComDataCU *pcCU, UInt uiAbsPartIdx, Pel *piOrg, Pel *piPCM, Pel *piPred, Pel *piResi, Pel *piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, const ComponentID compID)
Bool testWeightBiPred() const
Bool ProcessChannelSection(const ChannelType chType) const
Void setSkipFlagSubParts(Bool skip, UInt absPartIdx, UInt depth)
SChar * m_phQTTempCrossComponentPredictionAlpha[MAX_NUM_COMPONENT]
SChar * getPartitionSize()
SliceType getSliceType() const
TCoeff * getArlCoeff(ComponentID component)
static const UInt MAX_IDX_ADAPT_SR
TCoeff * m_ppcQTTempTUArlCoeff[MAX_NUM_COMPONENT]
Defines version information, constants and small in-line functions.
UInt Distortion
distortion measurement
Void getMvPredLeft(TComMv &rcMvPred) const
MESearchMethod
supported ME search methods
Void xTZSearchSelective(const TComDataCU *const pcCU, const TComPattern *const pcPatternKey, const Pel *const piRefY, const Int iRefStride, const TComMv *const pcMvSrchRngLT, const TComMv *const pcMvSrchRngRB, TComMv &rcMv, Distortion &ruiSAD, const TComMv *const pIntegerMv2Nx2NPred)
Void getInterMergeCandidates(UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField *pcMFieldNeighbours, UChar *puhInterDirNeighbours, Int &numValidMergeCand, UInt &numSpatialMergeCandidates, Int mrgCandIdx=-1) const
Construct a list of merging candidates.
TCoeff ** m_ppcQTTempArlCoeff[MAX_NUM_COMPONENT]
__inline Void xTZSearchHelp(const TComPattern *const pcPatternKey, IntTZSearchStruct &rcStruct, const Int iSearchX, const Int iSearchY, const UChar ucPointNr, const UInt uiDistance)
#define DEBUG_STRING_PASS_INTO_OPTIONAL(name, exp)
UChar * getExplicitRdpcmMode(ComponentID component)
const TComPPSRExt & getPpsRangeExtension() const
Int getStride(const ComponentID id) const
static const Int DM_CHROMA_IDX
chroma mode index for derived from luma intra mode
static const Int NUM_CHROMA_MODE
total number of chroma modes
static const Int MRG_MAX_NUM_CANDS
MERGE.
const TComSPSRExt & getSpsRangeExtension() const
SChar * getCrossComponentPredictionAlpha(ComponentID compID)
Int getMVPNum(RefPicList eRefPicList, UInt uiIdx) const
Void encodeTransformSubdivFlag(UInt uiSymbol, UInt uiCtx)
Void xEncIntraHeader(TComDataCU *pcCU, UInt uiTrDepth, UInt uiAbsPartIdx, Bool bLuma, Bool bChroma)
Void fillMvpCand(const UInt uiPartIdx, const UInt uiPartAddr, const RefPicList eRefPicList, const Int iRefIdx, AMVPInfo *pInfo) const
Void xEncSubdivCbfQT(TComTU &rTu, Bool bLuma, Bool bChroma)
static const Int MAX_TU_SIZE
estBitsSbacStruct * m_pcEstBitsSbac
Void setMergeFlagSubParts(Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth)
static Void crossComponentPrediction(TComTU &rTu, const ComponentID compID, const Pel *piResiL, const Pel *piResiC, Pel *piResiT, const Int width, const Int height, const Int strideL, const Int strideC, const Int strideT, const Bool reverse)
UChar * getTransformIdx()
global variables & functions (header)
Void setAllRefIdx(Int iRefIdx, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0)
Bool getFastMEForGenBLowDelayEnabled()
Void initPattern(Pel *piY, Int roiWidth, Int roiHeight, Int stride, Int bitDepthLuma, Int roiPosX, Int roiPosY)
set parameters from Pel buffers for accessing neighbouring pixels
UChar getQtRootCbf(UInt uiIdx) const
Int getROIYHeight() const
class for motion vector with reference index
static const UInt MAX_NUM_REF_LIST_ADAPT_SR
neighbouring pixel access class for all components
Void encodePredMode(TComDataCU *pcCU, UInt uiAbsPartIdx, Bool bRD=false)
encode prediction mode
Bool getClipForBiPredMeEnabled() const
Void xPatternSearchFast(const TComDataCU *const pcCU, const TComPattern *const pcPatternKey, const Pel *const piRefY, const Int iRefStride, const TComMv *const pcMvSrchRngLT, const TComMv *const pcMvSrchRngRB, TComMv &rcMv, Distortion &ruiSAD, const TComMv *const pIntegerMv2Nx2NPred)
Void xMotionEstimation(TComDataCU *pcCU, TComYuv *pcYuvOrg, Int iPartIdx, RefPicList eRefPicList, TComMv *pcMvPred, Int iRefIdxPred, TComMv &rcMv, UInt &ruiBits, Distortion &ruiCost, Bool bBi=false)
ChromaFormat GetChromaFormat() const
Bool isLastColumnCTUInTile() const
Void motionCompensation(TComDataCU *pcCU, TComYuv *pcYuvPred, RefPicList eRefPicList=REF_PIC_LIST_X, Int iPartIdx=-1)
Bool getUseReconBasedCrossCPredictionEstimate() const
Distortion xPatternRefinement(TComPattern *pcPatternKey, TComMv baseRefMv, Int iFrac, TComMv &rcMvFrac, Bool bAllowUseOfHadamard)
sub-function for motion vector refinement used in fractional-pel accuracy
SChar * getPredictionMode()
Void setExplicitRdpcmModePartRange(UInt rdpcmMode, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes)
Bool getMvdL1ZeroFlag() const
Void xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth)
Generate motion-compensated block.
TComYuv m_acYuvPred[NUM_REF_PIC_LIST_01]
Void setDistParamComp(ComponentID compIdx)
Void xEncCoeffQT(TComTU &rTu, ComponentID component, Bool bRealCoeff)
Void setTransformSkipPartRange(UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes)
Void xTZSearch(const TComDataCU *const pcCU, const TComPattern *const pcPatternKey, const Pel *const piRefY, const Int iRefStride, const TComMv *const pcMvSrchRngLT, const TComMv *const pcMvSrchRngRB, TComMv &rcMv, Distortion &ruiSAD, const TComMv *const pIntegerMv2Nx2NPred, const Bool bExtendedSettings)
static const TComMv s_acMvRefineH[9]
Void initTempBuff(ChromaFormat chromaFormatIDC)
Void xSetIntraResultLumaQT(TComYuv *pcRecoYuv, TComTU &rTu)
symmetric motion partition, 2Nx N
static Bool filteringIntraReferenceSamples(const ComponentID compID, UInt uiDirMode, UInt uiTuChWidth, UInt uiTuChHeight, const ChromaFormat chFmt, const Bool intraReferenceSmoothingDisabled)
Void setCbfPartRange(UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes)
UInt xGetMvpIdxBits(Int iIdx, Int iNum)
Void copyPartToPartComponent(const ComponentID id, TComYuv *pcYuvDst, const UInt uiPartIdx, const UInt uiWidthComponent, const UInt uiHeightComponent) const
static const TComMv s_acMvRefineQ[9]
UInt getStride(const ComponentID id) const
UInt GetTransformDepthRel() const
Int getNumberValidComponents() const
TComYuv m_pcQTTempTransformSkipTComYuv
Void setWpScalingDistParam(TComDataCU *pcCU, Int iRefIdx, RefPicList eRefPicListCur)
set wp tables
UChar getCbf(UInt uiIdx, ComponentID eType) const
__inline Void xTZ8PointSquareSearch(const TComPattern *const pcPatternKey, IntTZSearchStruct &rcStruct, const TComMv *const pcMvSrchRngLT, const TComMv *const pcMvSrchRngRB, const Int iStartX, const Int iStartY, const Int iDist)
Bool IsLastSection() const
Void xAddSymbolBitsInter(TComDataCU *pcCU, UInt &ruiBits)
UInt getLog2MaxTransformSkipBlockSize() const
Bool nextSection(const TComTU &parent)
Int m_aaiAdaptSR[MAX_NUM_REF_LIST_ADAPT_SR][MAX_IDX_ADAPT_SR]
#define DEBUG_STRING_SWAP(srt1, str2)
ChromaFormat getChromaFormatIdc() const
static const Int MAX_NUM_REF
max. number of entries in picture reference list
Int recon[MAX_NUM_CHANNEL_TYPE]
the bit depth as indicated in the SPS
UInt xUpdateCandList(UInt uiMode, Double uiCost, UInt uiFastCandNum, UInt *CandModeList, Double *CandCostList)
Void xCopyAMVPInfo(AMVPInfo *pSrc, AMVPInfo *pDst)
Bool getTransquantBypassEnabledFlag() const
Int getNumRefIdx(RefPicList e) const
UInt GetSectionNumber() const
UChar * m_puhQTTempTransformSkipFlag[MAX_NUM_COMPONENT]
TComMv m_acMvCand[AMVP_MAX_NUM_CANDS]
array of motion vector predictor candidates
UInt getZorderIdxInCtu() const
Distortion & getTotalDistortion()
Void xIntraCodingTUBlock(TComYuv *pcOrgYuv, TComYuv *pcPredYuv, TComYuv *pcResiYuv, Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE *MAX_CU_SIZE], const Bool checkCrossCPrediction, Distortion &ruiDist, const ComponentID compID, TComTU &rTu, Int default0Save1Load2=0)
Void getAllowedChromaDir(UInt uiAbsPartIdx, UInt *uiModeList) const
Void copyPartToPartComponentMxN(const ComponentID id, TComYuv *pcYuvDst, const TComRectangle &rect) const
Bool isInter(UInt uiPartIdx) const
Distortion xGetTemplateCost(TComDataCU *pcCU, UInt uiPartAddr, TComYuv *pcOrgYuv, TComYuv *pcTemplateCand, TComMv cMvCand, Int iMVPIdx, Int iMVPNum, RefPicList eRefPicList, Int iRefIdx, Int iSizeX, Int iSizeY)
Void xRecurIntraChromaCodingQT(TComYuv *pcOrgYuv, TComYuv *pcPredYuv, TComYuv *pcResiYuv, Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE *MAX_CU_SIZE], Distortion &ruiDist, TComTU &rTu)
Void setInterDirSubParts(UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth)
TComPicYuv * getPicYuvRec()
UInt GetAbsPartIdxTU() const
Void encodeCoeffNxN(TComTU &rTu, TCoeff *pcCoef, const ComponentID compID)
Void xInitTileBorders(const TComDataCU *const pcCU, TComPattern *pcPatternKey)
ChromaFormat getChromaFormatIdc()
UInt xModeBitsIntra(TComDataCU *pcCU, UInt uiMode, UInt uiPartOffset, UInt uiDepth, const ChannelType compID)
UInt getMaxTotalCUDepth() const
TCoeff ** m_ppcQTTempCoeff[MAX_NUM_COMPONENT]
PartSize
supported partition shape
UInt m_auiMVPIdxCost[AMVP_MAX_NUM_CANDS+1][AMVP_MAX_NUM_CANDS+1]
Bool getFastUDIUseMPMEnabled()
Bool testWeightPred() const
static Void offsetSubTUCBFs(TComTU &rTu, const ComponentID compID)
Void xPatternSearch(const TComPattern *const pcPatternKey, const Pel *piRefY, const Int iRefStride, const TComMv *const pcMvSrchRngLT, const TComMv *const pcMvSrchRngRB, TComMv &rcMv, Distortion &ruiSAD)
UInt getIntraSizeIdx(UInt uiAbsPartIdx) const
UInt getCoefScanIdx(const UInt uiAbsPartIdx, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) const
UChar * getIntraDir(const ChannelType channelType) const
Bool checkTMctsMvp(TComDataCU *pcCU, Int partIdx=-1)
Void xEstimateInterResidualQT(TComYuv *pcResi, Double &rdCost, UInt &ruiBits, Distortion &ruiDist, Distortion *puiZeroDist, TComTU &rTu)
TEncSbac * m_pcRDGoOnSbacCoder
Int iN
number of motion vector predictor candidates
symmetric motion partition, 2Nx2N
Int iSubShift
During cost calculations, if distortion exceeds this value, cost calculations may early-terminate...
Void setCrossComponentPredictionAlphaPartRange(SChar alphaValue, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes)
Void predIntraAng(const ComponentID compID, UInt uiDirMode, Pel *piOrg, UInt uiOrgStride, Pel *piPred, UInt uiStride, TComTU &rTu, const Bool bUseFilteredPredSamples, const Bool bUseLosslessDPCM=false)
static const UInt NUM_MV_PREDICTORS
Void encodeCoeff(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &bCodeDQP, Bool &codeChromaQpAdj)
encode coefficients
Bool getUseTransformSkip() const
static const Int FAST_UDI_MAX_RDMODE_NUM
maximum number of RD comparison in fast-UDI estimation loop
Int getTileLeftTopPelPosY() const
Void setAllMvField(TComMvField const &mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0)
Bool isIntra(UInt uiPartIdx) const
Void setPartSizeSubParts(PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth)
Void setTMctsMvpIsValid(Bool b)
Double calcRdCost(Double numBits, Double distortion, DFunc eDFunc=DF_DEFAULT)
Void estimateBit(estBitsSbacStruct *pcEstBitsSbac, Int width, Int height, ChannelType chType, COEFF_SCAN_TYPE scanType)
Void xSetSearchRange(const TComDataCU *const pcCU, const TComMv &cMvPred, const Int iSrchRng, TComMv &rcMvSrchRngLT, TComMv &rcMvSrchRngRB, const TComPattern *const pcPatternKey)
UInt getComponentScaleX(const ComponentID id) const
Void setTransformSkipSubParts(UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth)
static const Int LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME
QP' to use for mixed_lossy_lossless coding.
#define ADAPTIVE_QP_SELECTION
G382: Adaptive reconstruction levels, non-normative part for adaptive QP selection.
Void encodeIPCMInfo(TComDataCU *pcCU, UInt uiAbsPartIdx, Bool bRD=false)
Void clipMv(TComMv &rcMv) const
distortion parameter class
Bool isLosslessCoded(UInt absPartIdx) const
Void xExtDIFUpSamplingH(TComPattern *pcPattern)
Generate half-sample interpolated block.
static const Int AMVP_MAX_NUM_CANDS
AMVP: advanced motion vector prediction - max number of final candidates.
Void setIntraDirSubParts(const ChannelType channelType, const UInt uiDir, const UInt uiAbsPartIdx, const UInt uiDepth)
Void encodeQtCbfZero(TComTU &rTu, const ChannelType chType)
asymmetric motion partition, 2Nx( N/2) + 2Nx(3N/2)
Void getPartPosition(UInt partIdx, Int &xP, Int &yP, Int &nPSW, Int &nPSH) const
RD cost computation class.
#define HHI_RQT_INTRA_SPEEDUP
tests one best mode with full rqt
UInt xGetIntraBitsQT(TComTU &rTu, Bool bLuma, Bool bChroma, Bool bRealCoeff)
asymmetric motion partition, (3N/2)x2N + ( N/2)x2N
motion information handling classes (header)
static const Int MAX_INT
max. value of signed 32-bit integer
Void load(const TEncSbac *pSrc)
Void addClip(const TComYuv *pcYuvSrc0, const TComYuv *pcYuvSrc1, const UInt uiTrUnitIdx, const UInt uiPartSize, const BitDepths &clipBitDepths)
Void copyToPartYuv(TComYuv *pcYuvDst, const UInt uiDstPartIdx) const
Void getIntraDirPredictor(UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int *piMode=0) const
UInt getComponentScaleY(const ComponentID id) const
Void create(const UInt iWidth, const UInt iHeight, const ChromaFormat chromaFormatIDC)
Create YUV buffer.
MVP of above right block.
TComMv m_acMvPredictors[NUM_MV_PREDICTORS]
Void subtract(const TComYuv *pcYuvSrc0, const TComYuv *pcYuvSrc1, const UInt uiTrUnitIdx, const UInt uiPartSize)
Distortion m_maximumDistortionForEarlyExit
Void loadIntraDirMode(const TEncSbac *pScr, const ChannelType chType)
CostMode getCostMode() const
#define DEBUG_STRING_APPEND(str1, str2)
const UChar g_aucIntraModeNumFast_UseMPM[MAX_CU_DEPTH]
Int getBitDepth(ChannelType type) const
ValueType rightShift(const ValueType value, const Int shift)
Bool ProcessingAllQuadrants(const ComponentID compID) const
Int TCoeff
transform coefficient
Int getDifferentialLumaChromaBitDepth() const
Int getComponentScaleX(const ComponentID id) const
Pel * getAddr(const ComponentID id)
RefPicList
reference list index
Void xMergeEstimation(TComDataCU *pcCU, TComYuv *pcYuvOrg, Int iPartIdx, UInt &uiInterDir, TComMvField *pacMvField, UInt &uiMergeIndex, Distortion &ruiCost, TComMvField *cMvFieldNeighbours, UChar *uhInterDirNeighbours, Int &numValidMergeCand)
estimation of best merge coding
Void init(TEncCfg *pcEncCfg, TComTrQuant *pcTrQuant, Int iSearchRange, Int bipredSearchRange, MESearchMethod motionEstimationSearchMethod, const UInt maxCUWidth, const UInt maxCUHeight, const UInt maxTotalCUDepth, TEncEntropy *pcEntropyCoder, TComRdCost *pcRdCost, TEncSbac ***pppcRDSbacCoder, TEncSbac *pcRDGoOnSbacCoder)
UInt GetLog2LumaTrSize() const
ChromaFormat
chroma formats (according to semantics of chroma_format_idc)
UInt getCoefficientOffset(const ComponentID compID) const
Void getMvPredAboveRight(TComMv &rcMvPred) const
UInt getQuadtreeTULog2MinSize() const
const TComRectangle & getRect(const ComponentID compID) const
const BitDepths & getBitDepths() const
COEFF_SCAN_TYPE
coefficient scanning type used in ACS
TEncSbac *** m_pppcRDSbacCoder
encoder search class (header)
TEncEntropy * m_pcEntropyCoder
Distortion getCostOfVectorWithPredictor(const Int x, const Int y)
Bool getUseTransformSkipFast()
UInt g_auiZscanToRaster[MAX_NUM_PART_IDXS_IN_CTU_WIDTH *MAX_NUM_PART_IDXS_IN_CTU_WIDTH]
const TComPPS * getPPS() const
Void setQPSubParts(Int qp, UInt uiAbsPartIdx, UInt uiDepth)
Void copyToPic(UChar uiDepth)
MESearchMethod getMotionEstimationSearchMethod() const
#define DEBUG_STRING_PASS_INTO(name)
static Void getMvField(const TComDataCU *pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField &rcMvField)
UChar * getTransformSkip(ComponentID compID)
ChromaFormat getChromaFormat() const
Void xExtDIFUpSamplingQ(TComPattern *pcPatternKey, TComMv halfPelRef)
Generate quarter-sample interpolated blocks.
UChar * m_puhQTTempCbf[MAX_NUM_COMPONENT]
Bool getIntraSmoothingDisabledFlag() const
Void getPartIndexAndSize(UInt uiPartIdx, UInt &ruiPartAddr, Int &riWidth, Int &riHeight) const
Void setDistParam(UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc, DistParam &rcDistParam)
Void xStoreIntraResultQT(const ComponentID compID, TComTU &rTu)
Void encodeIntraDirModeChroma(TComDataCU *pcCU, UInt uiAbsPartIdx)
encode intra direction for chroma
MESearchMethod m_motionEstimationSearchMethod
Void xGetBlkBits(PartSize eCUMode, Bool bPSlice, Int iPartIdx, UInt uiLastMode, UInt uiBlkBit[3])
Bool ProcessComponentSection(const ComponentID compID) const
const TComSPS & getSPS() const
Void invTransformNxN(TComTU &rTu, const ComponentID compID, Pel *pcResidual, const UInt uiStride, TCoeff *pcCoeff, const QpParam &cQP)
Void IPCMSearch(TComDataCU *pcCU, TComYuv *pcOrgYuv, TComYuv *rpcPredYuv, TComYuv *rpcResiYuv, TComYuv *rpcRecoYuv)
Function for PCM mode estimation.
Void setPredictor(TComMv &rcMv)
Int getLog2DiffMaxMinCodingBlockSize() const
Bool * getCUTransquantBypass()
asymmetric motion partition, ( N/2)x2N + (3N/2)x2N
Void selectLambda(const ComponentID compIdx)
Pel * m_pSharedPredTransformSkip[MAX_NUM_COMPONENT]
UInt GetAbsPartIdxNumParts() const
Void estIntraPredLumaQT(TComDataCU *pcCU, TComYuv *pcOrgYuv, TComYuv *pcPredYuv, TComYuv *pcResiYuv, TComYuv *pcRecoYuv, Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE *MAX_CU_SIZE])
Void setAllMvd(TComMv const &rcMvd, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0)
Void xEstimateMvPredAMVP(TComDataCU *pcCU, TComYuv *pcOrgYuv, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv &rcMvPred, Bool bFilled=false, Distortion *puiDistBiP=0)
Bool getTMCTSSEITileConstraint()
#define DEBUG_STRING_FN_DECLARE(name)
TComTrQuant * m_pcTrQuant
const UChar g_chroma422IntraAngleMappingTable[NUM_INTRA_MODE]
ChromaFormat getChromaFormat() const
TComYuv * m_pcQTTempTComYuv
Void predInterSearch(TComDataCU *pcCU, TComYuv *pcOrgYuv, TComYuv *pcPredYuv, TComYuv *pcResiYuv, TComYuv *pcRecoYuv, Bool bUseRes=false, Bool bUseMRG=false)
encoder estimation - inter prediction (non-skip)
Int getList1IdxToList0Idx(Int list1Idx) const
UInt getQuadtreeTULog2MaxSize() const
Void encodeCrossComponentPrediction(TComTU &rTu, ComponentID compID)
static const Int MAX_CU_SIZE
= 1<<(MAX_CU_DEPTH)
UInt xGetIntraBitsQTChroma(TComTU &rTu, ComponentID compID, Bool bRealCoeff)
TComInterpolationFilter m_if
__inline Void xTZ8PointDiamondSearch(const TComPattern *const pcPatternKey, IntTZSearchStruct &rcStruct, const TComMv *const pcMvSrchRngLT, const TComMv *const pcMvSrchRngRB, const Int iStartX, const Int iStartY, const Int iDist, const Bool bCheckCornersAtDist1)
UInt getQuadtreeTULog2MinSize() const
Void setCostScale(Int iCostScale)
Void setCbfSubParts(const UInt uiCbf[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth)
static Void filterVer(Int bitDepth, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Bool isFirst, Bool isLast, TFilterCoeff const *coeff)
Filter a block of samples (vertical)
transform and quantization class
static const Double MAX_DOUBLE
max. value of Double-type value
Pel * getAddr(const ComponentID ch)
Int getTileRightBottomPelPosY() const
Int getTileRightBottomPelPosX() const
TCoeff * m_pcQTTempTUCoeff[MAX_NUM_COMPONENT]
Void xSetIntraResultChromaQT(TComYuv *pcRecoYuv, TComTU &rTu)
Void xEncodeInterResidualQT(const ComponentID compID, TComTU &rTu)
Void store(TEncSbac *pDest) const
#define MCTS_ENC_CHECK
Temporal MCTS encoder constraint and decoder checks. Also requires SEITMCTSTileConstraint to be enabl...
Void encodeQtCbf(TComTU &rTu, const ComponentID compID, const Bool lowestLevel)
Void xGetInterPredictionError(TComDataCU *pcCU, TComYuv *pcYuvOrg, Int iPartIdx, Distortion &ruiSAD, Bool Hadamard)
Void encodeCUTransquantBypassFlag(TComDataCU *pcCU, UInt uiAbsPartIdx, Bool bRD=false)
Void encodePartSize(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD=false)
encode partition size
TComCUMvField * getCUMvField(RefPicList e)
UInt getLog2ParallelMergeLevelMinus2() const
Distortion getDistPart(Int bitDepth, const Pel *piCur, Int iCurStride, const Pel *piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, const ComponentID compID, DFunc eDFunc=DF_SSE)
TCoeff * getCoeff(ComponentID component)
Bool getRestrictMESampling() const
basic motion vector class
UInt getPCMBitDepth(ChannelType type) const
UInt numSpatialMVPCandidates
UInt getQuadtreeTULog2MaxSize() const
Void encodeIntraDirModeLuma(TComDataCU *pcCU, UInt absPartIdx, Bool isMultiplePU=false)
encode intra direction for luma
Void initIntraPatternChType(TComTU &rTu, const ComponentID compID, const Bool bFilterRefSamples)
set parameters from CU data for accessing intra data
Bool getFastMEAssumingSmootherMVEnabled() const
static const UInt MAX_UINT
max. value of unsigned 32-bit integer
Int getComponentScaleY(const ComponentID id) const
Void xSetInterResidualQTData(TComYuv *pcResi, Bool bSpatial, TComTU &rTu)
UInt getMaxNumMergeCand()
Void encodeMergeIndex(TComDataCU *pcCU, UInt uiAbsPartIdx, Bool bRD=false)
encode merge index
Void xRecurIntraCodingLumaQT(TComYuv *pcOrgYuv, TComYuv *pcPredYuv, TComYuv *pcResiYuv, Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE *MAX_CU_SIZE], Distortion &ruiDistY, Bool bCheckFirst, Double &dRDCost, TComTU &rTu)
Void setMergeIndexSubParts(UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth)
Void xStoreCrossComponentPredictionResult(Pel *pResiLuma, const Pel *pBestLuma, TComTU &rTu, const Int xOffset, const Int yOffset, const Int strideResi, const Int strideBest)
__inline Void xTZ2PointSearch(const TComPattern *const pcPatternKey, IntTZSearchStruct &rcStruct, const TComMv *const pcMvSrchRngLT, const TComMv *const pcMvSrchRngRB)
Int getPatternLStride() const
Bool isBipredRestriction(UInt puIdx) const
TComYuv m_filteredBlockTmp[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS]
asymmetric motion partition, 2Nx(3N/2) + 2Nx( N/2)
Void getMvPredAbove(TComMv &rcMvPred) const
Void divideByPowerOf2(const Int i)
shift right with rounding
symmetric motion partition, Nx N
encoder configuration class
Void xPatternSearchFracDIF(Bool bIsLosslessCoded, TComPattern *pcPatternKey, Pel *piRefY, Int iRefStride, TComMv *pcMvInt, TComMv &rcMvHalf, TComMv &rcMvQter, Distortion &ruiCost)
Pel * getPCMSample(ComponentID component)
const WPScalingParam * wpCur
Void encodeQtRootCbfZero()
Void set(Short iHor, Short iVer)
UInt g_auiRasterToPelX[MAX_NUM_PART_IDXS_IN_CTU_WIDTH *MAX_NUM_PART_IDXS_IN_CTU_WIDTH]
Void xLoadIntraResultQT(const ComponentID compID, TComTU &rTu)
Void setAllMv(TComMv const &rcMv, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0)
TComYuv m_filteredBlock[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS]
UInt getQuadtreeTUMaxDepthInter() const
Void encodePredInfo(TComDataCU *pcCU, UInt uiAbsPartIdx)
Void setMVPIdxSubParts(Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth)
SChar xCalcCrossComponentPredictionAlpha(TComTU &rTu, const ComponentID compID, const Pel *piResiL, const Pel *piResiC, const Int width, const Int height, const Int strideL, const Int strideC)
Void encodeSkipFlag(TComDataCU *pcCU, UInt uiAbsPartIdx, Bool bRD=false)
Int getTileLeftTopPelPosX() const
Void getWpScaling(TComDataCU *const pcCU, const Int iRefIdx0, const Int iRefIdx1, WPScalingParam *&wp0, WPScalingParam *&wp1)
derivation of wp tables
Void encodeResAndCalcRdInterCU(TComDataCU *pcCU, TComYuv *pcYuvOrg, TComYuv *pcYuvPred, TComYuv *pcYuvResi, TComYuv *pcYuvResiBest, TComYuv *pcYuvRec, Bool bSkipResidual)
encode residual and compute rd-cost for inter mode
UInt getNumberValidComponents() const
Void getTilePosition(const TComDataCU *const pcCU, UInt &tileXPosInCtus, UInt &tileYPosInCtus, UInt &tileWidthtInCtus, UInt &tileHeightInCtus)
Void selectMotionLambda(Bool bSad, Int iAdd, Bool bIsTransquantBypass)
Void transformNxN(TComTU &rTu, const ComponentID compID, Pel *pcResidual, const UInt uiStride, TCoeff *rpcCoeff, TCoeff *rpcArlCoeff, TCoeff &uiAbsSum, const QpParam &cQP)
static const UInt NUM_MOST_PROBABLE_MODES
Pel * getAddrPix(const ComponentID id, const UInt iPixX, const UInt iPixY)
Void copyPartToPartYuv(TComYuv *pcYuvDst, const UInt uiPartIdx, const UInt uiWidth, const UInt uiHeight) const
UInt getBitsOfVectorWithPredictor(const Int x, const Int y)
#define NTAPS_LUMA
Number of taps for luma.
Void clear()
clear YUV buffer
TComPic * getRefPic(RefPicList e, Int iRefIdx)
Void xCheckBestMVP(TComDataCU *pcCU, RefPicList eRefPicList, TComMv cMv, TComMv &rcMvPred, Int &riMVPIdx, UInt &ruiBits, Distortion &ruiCost)
TComMv m_integerMv2Nx2N[NUM_REF_PIC_LIST_01][MAX_NUM_REF]
symmetric motion partition, Nx2N
#define DEBUG_STRING_NEW(name)
Defines types and objects for environment-variable-based debugging and feature control.
FastInterSearchMode getFastInterSearchMode() const
#define DEBUG_STRING_CHANNEL_CONDITION(compID)
UInt g_auiRasterToPelY[MAX_NUM_PART_IDXS_IN_CTU_WIDTH *MAX_NUM_PART_IDXS_IN_CTU_WIDTH]
static Void filterHor(Int bitDepth, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Bool isLast, TFilterCoeff const *coeff)
Filter a block of samples (horizontal)
UInt getMaxCUWidth() const
const TComSPS * getSPS() const
UInt getNumberOfWrittenBits()
Void setTileBorders(Int tileLeftTopPelPosX, Int tileLeftTopPelPosY, Int tileRightBottomPelPosX, Int tileRightBottomPelPosY)
Void estIntraPredChromaQT(TComDataCU *pcCU, TComYuv *pcOrgYuv, TComYuv *pcPredYuv, TComYuv *pcResiYuv, TComYuv *pcRecoYuv, Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE *MAX_CU_SIZE])
Void xWeightedPredictionUni(TComDataCU *const pcCU, const TComYuv *const pcYuvSrc, const UInt uiPartAddr, const Int iWidth, const Int iHeight, const RefPicList eRefPicList, TComYuv *pcYuvPred, const Int iRefIdx=-1)
weighted prediction for uni-pred
const UChar g_aucIntraModeNumFast_NotUseMPM[MAX_CU_DEPTH]
static Bool UseDPCMForFirstPassIntraEstimation(TComTU &rTu, const UInt uiDirMode)
Void setTrIdxSubParts(UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth)