Commit 5e7c70d2 authored by Alexey Filippov's avatar Alexey Filippov
Browse files

cShift-related modifications and macro-related clean-up in UnitTools.cpp

parent 21dbc8a3
......@@ -380,6 +380,10 @@ Distortion RdCost::getDistPart( const CPelBuf &org, const CPelBuf &cur, int bitD
#if WCG_EXT
if( orgLuma )
{
#if JVET_N0671_RDCOST_FIX
cDtParam.cShiftX = getComponentScaleX(compID, m_cf);
cDtParam.cShiftY = getComponentScaleY(compID, m_cf);
#endif
if( isChroma(compID) )
{
cDtParam.orgLuma = *orgLuma;
......@@ -3025,9 +3029,10 @@ Distortion RdCost::xGetSSE_WTD( const DistParam &rcDtParam )
const Pel* piOrgLuma = rcDtParam.orgLuma.buf;
const int iStrideOrgLuma = rcDtParam.orgLuma.stride;
#if JVET_N0671_RDCOST_FIX
const int cShift = 0;
const size_t cShift = rcDtParam.cShiftX;
const size_t cShiftY = rcDtParam.cShiftY;
#else
const int cShift = (rcDtParam.compID==COMPONENT_Y) ? 0 : 1; // assume 420, could use getComponentScaleX, getComponentScaleY
const size_t cShift = (rcDtParam.compID==COMPONENT_Y) ? 0 : 1; // assume 420, could use getComponentScaleX, getComponentScaleY
#endif
Distortion uiSum = 0;
......@@ -3040,7 +3045,12 @@ Distortion RdCost::xGetSSE_WTD( const DistParam &rcDtParam )
}
piOrg += iStrideOrg;
piCur += iStrideCur;
#if JVET_N0671_RDCOST_FIX
piOrgLuma += iStrideOrgLuma<<cShiftY;
#else
piOrgLuma += iStrideOrgLuma<<cShift;
#endif
}
return ( uiSum );
}
......@@ -3061,9 +3071,10 @@ Distortion RdCost::xGetSSE2_WTD( const DistParam &rcDtParam )
const Pel* piOrgLuma = rcDtParam.orgLuma.buf;
const size_t iStrideOrgLuma = rcDtParam.orgLuma.stride;
#if JVET_N0671_RDCOST_FIX
const size_t cShift = 0;
const size_t cShift = rcDtParam.cShiftX;
const size_t cShiftY = rcDtParam.cShiftY;
#else
const size_t cShift = (rcDtParam.compID==COMPONENT_Y) ? 0 : 1; // assume 420, could use getComponentScaleX, getComponentScaleY
const size_t cShift = (rcDtParam.compID==COMPONENT_Y) ? 0 : 1; // assume 420, could use getComponentScaleX, getComponentScaleY
#endif
Distortion uiSum = 0;
......@@ -3074,7 +3085,11 @@ Distortion RdCost::xGetSSE2_WTD( const DistParam &rcDtParam )
uiSum += getWeightedMSE(rcDtParam.compID, piOrg[1 ], piCur[1 ], uiShift, piOrgLuma[size_t(1)<<cShift]); // piOrg[1] - piCur[1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
piOrg += iStrideOrg;
piCur += iStrideCur;
#if JVET_N0671_RDCOST_FIX
piOrgLuma += iStrideOrgLuma<<cShiftY;
#else
piOrgLuma += iStrideOrgLuma<<cShift;
#endif
}
return ( uiSum );
}
......@@ -3095,9 +3110,10 @@ Distortion RdCost::xGetSSE4_WTD( const DistParam &rcDtParam )
const Pel* piOrgLuma = rcDtParam.orgLuma.buf;
const size_t iStrideOrgLuma = rcDtParam.orgLuma.stride;
#if JVET_N0671_RDCOST_FIX
const size_t cShift = 0;
const size_t cShift = rcDtParam.cShiftX;
const size_t cShiftY = rcDtParam.cShiftY;
#else
const size_t cShift = (rcDtParam.compID==COMPONENT_Y) ? 0 : 1; // assume 420, could use getComponentScaleX, getComponentScaleY
const size_t cShift = (rcDtParam.compID==COMPONENT_Y) ? 0 : 1; // assume 420, could use getComponentScaleX, getComponentScaleY
#endif
Distortion uiSum = 0;
......@@ -3110,7 +3126,11 @@ Distortion RdCost::xGetSSE4_WTD( const DistParam &rcDtParam )
uiSum += getWeightedMSE(rcDtParam.compID, piOrg[3 ], piCur[3 ], uiShift, piOrgLuma[size_t(3)<<cShift] ); // piOrg[3] - piCur[3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
piOrg += iStrideOrg;
piCur += iStrideCur;
#if JVET_N0671_RDCOST_FIX
piOrgLuma += iStrideOrgLuma<<cShiftY;
#else
piOrgLuma += iStrideOrgLuma<<cShift;
#endif
}
return ( uiSum );
}
......@@ -3131,9 +3151,10 @@ Distortion RdCost::xGetSSE8_WTD( const DistParam &rcDtParam )
const Pel* piOrgLuma = rcDtParam.orgLuma.buf;
const size_t iStrideOrgLuma = rcDtParam.orgLuma.stride;
#if JVET_N0671_RDCOST_FIX
const size_t cShift = 0;
const size_t cShift = rcDtParam.cShiftX;
const size_t cShiftY = rcDtParam.cShiftY;
#else
const size_t cShift = (rcDtParam.compID==COMPONENT_Y) ? 0 : 1; // assume 420, could use getComponentScaleX, getComponentScaleY
const size_t cShift = (rcDtParam.compID==COMPONENT_Y) ? 0 : 1; // assume 420, could use getComponentScaleX, getComponentScaleY
#endif
Distortion uiSum = 0;
......@@ -3150,7 +3171,11 @@ Distortion RdCost::xGetSSE8_WTD( const DistParam &rcDtParam )
uiSum += getWeightedMSE(rcDtParam.compID, piOrg[7 ], piCur[7 ], uiShift, piOrgLuma[size_t(7)<<cShift ]); // piOrg[7] - piCur[7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
piOrg += iStrideOrg;
piCur += iStrideCur;
#if JVET_N0671_RDCOST_FIX
piOrgLuma += iStrideOrgLuma<<cShiftY;
#else
piOrgLuma += iStrideOrgLuma<<cShift;
#endif
}
return ( uiSum );
}
......@@ -3170,9 +3195,10 @@ Distortion RdCost::xGetSSE16_WTD( const DistParam &rcDtParam )
const Pel* piOrgLuma = rcDtParam.orgLuma.buf;
const size_t iStrideOrgLuma = rcDtParam.orgLuma.stride;
#if JVET_N0671_RDCOST_FIX
const size_t cShift = 0;
const size_t cShift = rcDtParam.cShiftX;
const size_t cShiftY = rcDtParam.cShiftY;
#else
const size_t cShift = (rcDtParam.compID==COMPONENT_Y) ? 0 : 1; // assume 420, could use getComponentScaleX, getComponentScaleY
const size_t cShift = (rcDtParam.compID==COMPONENT_Y) ? 0 : 1; // assume 420, could use getComponentScaleX, getComponentScaleY
#endif
Distortion uiSum = 0;
uint32_t uiShift = DISTORTION_PRECISION_ADJUSTMENT(rcDtParam.bitDepth) << 1;
......@@ -3196,7 +3222,12 @@ Distortion RdCost::xGetSSE16_WTD( const DistParam &rcDtParam )
uiSum += getWeightedMSE(rcDtParam.compID, piOrg[15 ], piCur[15 ], uiShift, piOrgLuma[size_t(15)<<cShift ]); //piOrg[15] - piCur[15]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
piOrg += iStrideOrg;
piCur += iStrideCur;
#if JVET_N0671_RDCOST_FIX
piOrgLuma += iStrideOrgLuma<<cShiftY;
#else
piOrgLuma += iStrideOrgLuma<<cShift;
#endif
}
return ( uiSum );
}
......@@ -3216,9 +3247,10 @@ Distortion RdCost::xGetSSE16N_WTD( const DistParam &rcDtParam )
const Pel* piOrgLuma = rcDtParam.orgLuma.buf;
const size_t iStrideOrgLuma = rcDtParam.orgLuma.stride;
#if JVET_N0671_RDCOST_FIX
const size_t cShift = 0;
const size_t cShift = rcDtParam.cShiftX;
const size_t cShiftY = rcDtParam.cShiftY;
#else
const size_t cShift = (rcDtParam.compID==COMPONENT_Y) ? 0 : 1; // assume 420, could use getComponentScaleX, getComponentScaleY
const size_t cShift = (rcDtParam.compID==COMPONENT_Y) ? 0 : 1; // assume 420, could use getComponentScaleX, getComponentScaleY
#endif
Distortion uiSum = 0;
uint32_t uiShift = DISTORTION_PRECISION_ADJUSTMENT(rcDtParam.bitDepth) << 1;
......@@ -3245,7 +3277,11 @@ Distortion RdCost::xGetSSE16N_WTD( const DistParam &rcDtParam )
}
piOrg += iStrideOrg;
piCur += iStrideCur;
#if JVET_N0671_RDCOST_FIX
piOrgLuma += iStrideOrgLuma<<cShiftY;
#else
piOrgLuma += iStrideOrgLuma<<cShift;
#endif
}
return ( uiSum );
}
......@@ -3265,9 +3301,10 @@ Distortion RdCost::xGetSSE32_WTD( const DistParam &rcDtParam )
const Pel* piOrgLuma = rcDtParam.orgLuma.buf;
const size_t iStrideOrgLuma = rcDtParam.orgLuma.stride;
#if JVET_N0671_RDCOST_FIX
const size_t cShift = 0;
const size_t cShift = rcDtParam.cShiftX;
const size_t cShiftY = rcDtParam.cShiftY;
#else
const size_t cShift = (rcDtParam.compID==COMPONENT_Y) ? 0 : 1; // assume 420, could use getComponentScaleX, getComponentScaleY
const size_t cShift = (rcDtParam.compID==COMPONENT_Y) ? 0 : 1; // assume 420, could use getComponentScaleX, getComponentScaleY
#endif
Distortion uiSum = 0;
......@@ -3308,7 +3345,11 @@ Distortion RdCost::xGetSSE32_WTD( const DistParam &rcDtParam )
uiSum += getWeightedMSE(rcDtParam.compID, piOrg[31], piCur[31], uiShift, piOrgLuma[size_t(31)<<cShift ]); // iTemp = piOrg[31] - piCur[31]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
piOrg += iStrideOrg;
piCur += iStrideCur;
#if JVET_N0671_RDCOST_FIX
piOrgLuma += iStrideOrgLuma<<cShiftY;
#else
piOrgLuma += iStrideOrgLuma<<cShift;
#endif
}
return ( uiSum );
}
......@@ -3328,7 +3369,8 @@ Distortion RdCost::xGetSSE64_WTD( const DistParam &rcDtParam )
const Pel* piOrgLuma = rcDtParam.orgLuma.buf;
const size_t iStrideOrgLuma = rcDtParam.orgLuma.stride;
#if JVET_N0671_RDCOST_FIX
const size_t cShift = 0;
const size_t cShift = rcDtParam.cShiftX;
const size_t cShiftY = rcDtParam.cShiftY;
#else
const size_t cShift = (rcDtParam.compID==COMPONENT_Y) ? 0 : 1; // assume 420, could use getComponentScaleX, getComponentScaleY
#endif
......@@ -3403,7 +3445,12 @@ Distortion RdCost::xGetSSE64_WTD( const DistParam &rcDtParam )
uiSum += getWeightedMSE(rcDtParam.compID, piOrg[63], piCur[63], uiShift, piOrgLuma[size_t(63)<<cShift]); // iTemp = piOrg[63] - piCur[63]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
piOrg += iStrideOrg;
piCur += iStrideCur;
#if JVET_N0671_RDCOST_FIX
piOrgLuma += iStrideOrgLuma<<cShiftY;
#else
piOrgLuma += iStrideOrgLuma<<cShift;
#endif
}
return ( uiSum );
}
......
......@@ -87,10 +87,15 @@ public:
// (vertical) subsampling shift (for reducing complexity)
// - 0 = no subsampling, 1 = even rows, 2 = every 4th, etc.
int subShift;
#if JVET_N0671_RDCOST_FIX
int cShiftX;
int cShiftY;
#endif
DistParam() :
org(), cur(), step( 1 ), bitDepth( 0 ), useMR( false ), applyWeight( false ), isBiPred( false ), wpCur( nullptr ), compID( MAX_NUM_COMPONENT ), maximumDistortionForEarlyExit( std::numeric_limits<Distortion>::max() ), subShift( 0 )
#if JVET_N0671_RDCOST_FIX
, cShiftX(-1), cShiftY(-1)
#endif
{ }
};
......@@ -112,6 +117,9 @@ private:
static uint32_t m_signalType;
static double m_chromaWeight;
static int m_lumaBD;
#if JVET_N0671_RDCOST_FIX
ChromaFormat m_cf;
#endif // JVET_N0671_RDCOST_FIX
#endif
double m_DistScale;
double m_dLambdaMotionSAD[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/];
......@@ -128,6 +136,9 @@ public:
virtual ~RdCost();
#if WCG_EXT
#if JVET_N0671_RDCOST_FIX
void setChromaFormat ( const ChromaFormat & _cf) { m_cf = _cf; }
#endif
double calcRdCost ( uint64_t fracBits, Distortion distortion, bool useUnadjustedLambda = true );
#else
double calcRdCost ( uint64_t fracBits, Distortion distortion );
......
......@@ -50,6 +50,10 @@
#include <assert.h>
#include <cassert>
#define JVET_N0470_SMVD_FIX 1 // remove mvd_l1_zero_flag condition, align to spec text.
#define JVET_N0235_SMVD_SPS 1
#define JVET_N0671 1
#if JVET_N0671
......@@ -65,10 +69,6 @@
#endif //JVET_N0671
#define JVET_N0470_SMVD_FIX 1 // remove mvd_l1_zero_flag condition, align to spec text.
#define JVET_N0235_SMVD_SPS 1
#define JVET_N0843_BVP_SIMPLIFICATION 1
#define JVET_N0448_N0380 1 // When MaxNumMergeCand is 1, MMVD_BASE_MV_NUM is inferred to be 1.
......
......@@ -987,11 +987,11 @@ uint32_t PU::getFinalIntraMode( const PredictionUnit &pu, const ChannelType &chT
uiIntraMode = lumaPU.intraDir[0];
}
if( pu.chromaFormat == CHROMA_422 && !isLuma( chType )
#if JVET_N0671_CHROMA_FORMAT_422
&& uiIntraMode < NUM_LUMA_MODE
if( pu.chromaFormat == CHROMA_422 && !isLuma( chType ) && uiIntraMode < NUM_LUMA_MODE ) // map directional, planar and dc
#else
if( pu.chromaFormat == CHROMA_422 && !isLuma( chType ) )
#endif //JVET_N0671_CHROMA_FORMAT_422
) // map directional, planar and dc
{
uiIntraMode = g_chroma422IntraAngleMappingTable[uiIntraMode];
}
......
......@@ -3707,6 +3707,9 @@ Distortion EncCu::getDistortionDb( CodingStructure &cs, CPelBuf org, CPelBuf rec
{
Distortion dist = 0;
#if WCG_EXT
#if JVET_N0671_RDCOST_FIX
m_pcRdCost->setChromaFormat(cs.sps->getChromaFormatIdc());
#endif
CPelBuf orgLuma = cs.picture->getOrigBuf( cs.area.blocks[COMPONENT_Y] );
if ( m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || (
m_pcEncCfg->getReshaper() && ( cs.slice->getReshapeInfo().getUseSliceReshaper() && m_pcReshape->getCTUFlag() ) ) )
......@@ -4140,6 +4143,9 @@ void EncCu::xEncodeDontSplit( CodingStructure &cs, Partitioner &partitioner )
#if REUSE_CU_RESULTS
void EncCu::xReuseCachedResult( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &partitioner )
{
#if JVET_N0671_RDCOST_FIX
m_pcRdCost->setChromaFormat(tempCS->sps->getChromaFormatIdc());
#endif
BestEncInfoCache* bestEncCache = dynamic_cast<BestEncInfoCache*>( m_modeCtrl );
CHECK( !bestEncCache, "If this mode is chosen, mode controller has to implement the mode caching capabilities" );
EncTestMode cachedMode;
......
......@@ -6287,6 +6287,10 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par
{
const UnitArea& currArea = partitioner.currArea();
const SPS &sps = *cs.sps;
#if JVET_N0671_RDCOST_FIX
m_pcRdCost->setChromaFormat(sps.getChromaFormatIdc());
#endif
const uint32_t numValidComp = getNumberValidComponents( sps.getChromaFormatIdc() );
const uint32_t numTBlocks = getNumberValidTBlocks ( *cs.pcv );
const CodingUnit &cu = *cs.getCU(partitioner.chType);
......@@ -6921,6 +6925,10 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa
, const bool luma, const bool chroma
)
{
#if JVET_N0671_RDCOST_FIX
m_pcRdCost->setChromaFormat(cs.sps->getChromaFormatIdc());
#endif
CodingUnit &cu = *cs.getCU( partitioner.chType );
const ChromaFormat format = cs.area.chromaFormat;;
......
......@@ -1581,6 +1581,9 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp
}
CodingStructure &cs = *tu.cs;
#if JVET_N0671_RDCOST_FIX
m_pcRdCost->setChromaFormat(cs.sps->getChromaFormatIdc());
#endif
const CompArea &area = tu.blocks[compID];
const SPS &sps = *cs.sps;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment