Commit cff4f429 authored by jamesxxiu's avatar jamesxxiu

remove duplicated code of SAD calculation

parent 2c9f0c00
......@@ -91,25 +91,6 @@ void addBIOAvgCore(const Pel* src0, int src0Stride, const Pel* src1, int src1Str
pGradX0 += gradStride; pGradX1 += gradStride; pGradY0 += gradStride; pGradY1 += gradStride;
}
}
Distortion calcHighBDSADCore(const Pel* src0, int src0Stride, const Pel* src1, int src1Stride, int width, int height, int bitDepth)
{
const uint32_t distortionShift = DISTORTION_PRECISION_ADJUSTMENT(bitDepth - 8);
Distortion sum = 0;
for (int rows = 0; rows < height; rows++)
{
for (int cols = 0; cols < width; cols++)
{
sum += abs(src0[cols] - src1[cols]);
}
src0 += src0Stride;
src1 += src1Stride;
}
return (sum >> distortionShift);
}
#endif
template<typename T>
......@@ -148,7 +129,6 @@ PelBufferOps::PelBufferOps()
addAvg8 = addAvgCore<Pel>;
#if JVET_K0485_BIO
addBIOAvg4 = addBIOAvgCore;
calcHighBDSAD = calcHighBDSADCore;
#endif
reco4 = reconstructCore<Pel>;
......
......@@ -70,7 +70,6 @@ struct PelBufferOps
void ( *linTf8 ) ( const Pel* src0, int src0Stride, Pel *dst, int dstStride, int width, int height, int scale, int shift, int offset, const ClpRng& clpRng, bool bClip );
#if JVET_K0485_BIO
void(*addBIOAvg4) (const Pel* src0, int src0Stride, const Pel* src1, int src1Stride, Pel *dst, int dstStride, const Pel *pGradX0, const Pel *pGradX1, const Pel *pGradY0, const Pel*pGradY1, int gradStride, int width, int height, int tmpx, int tmpy, int shift, int offset, const ClpRng& clpRng);
Distortion(*calcHighBDSAD) (const Pel* src0, int src0Stride, const Pel* src1, int src1Stride, int width, int height, int bitDepth);
#endif
};
......
......@@ -1514,9 +1514,6 @@ bool InterPrediction::xCalcBiPredSubBlkDist(const PredictionUnit &pu, const Pel*
m_bioSubBlkDistThres >>= distortionShift;
DistParam cDistParam;
cDistParam.applyWeight = false;
cDistParam.useMR = false;
Distortion dist = 0;
for (int yu = 0, blkIdx = 0; yu < yUnit; yu++)
{
......@@ -1525,7 +1522,8 @@ bool InterPrediction::xCalcBiPredSubBlkDist(const PredictionUnit &pu, const Pel*
const Pel* pPred0 = pYuvSrc0 + ((yu*src0Stride + xu) << 2);
const Pel* pPred1 = pYuvSrc1 + ((yu*src1Stride + xu) << 2);
m_bioPredSubBlkDist[blkIdx] = g_pelBufOP.calcHighBDSAD(pPred0, src0Stride, pPred1, src1Stride, (1 << 2), (1 << 2), clipbd);
m_pcRdCost->setDistParam(cDistParam, pPred0, pPred1, src0Stride, src1Stride, clipbd, COMPONENT_Y, (1 << 2), (1 << 2), 0, 1, false, true);
m_bioPredSubBlkDist[blkIdx] = cDistParam.distFunc(cDistParam);
dist += m_bioPredSubBlkDist[blkIdx];
}
}
......
......@@ -326,7 +326,11 @@ void RdCost::setDistParam( DistParam &rcDP, const CPelBuf &org, const CPelBuf &c
rcDP.maximumDistortionForEarlyExit = std::numeric_limits<Distortion>::max();
}
#if JVET_K0485_BIO
void RdCost::setDistParam( DistParam &rcDP, const Pel* pOrg, const Pel* piRefY, int iOrgStride, int iRefStride, int bitDepth, ComponentID compID, int width, int height, int subShiftMode, int step, bool useHadamard, bool bio )
#else
void RdCost::setDistParam( DistParam &rcDP, const Pel* pOrg, const Pel* piRefY, int iOrgStride, int iRefStride, int bitDepth, ComponentID compID, int width, int height, int subShiftMode, int step, bool useHadamard )
#endif
{
rcDP.bitDepth = bitDepth;
rcDP.compID = compID;
......@@ -347,6 +351,13 @@ void RdCost::setDistParam( DistParam &rcDP, const Pel* pOrg, const Pel* piRefY,
CHECK( useHadamard || rcDP.useMR || subShiftMode > 0, "only used in xDirectMCCost with these default parameters (so far...)" );
#if JVET_K0485_BIO
if (bio)
{
rcDP.distFunc = xGetSAD;
return;
}
#endif
if( width == 12 )
{
rcDP.distFunc = m_afpDistortFunc[ DF_SAD12 ];
......
......@@ -152,7 +152,11 @@ public:
void setDistParam( DistParam &rcDP, const CPelBuf &org, const Pel* piRefY , int iRefStride, int bitDepth, ComponentID compID, int subShiftMode = 0, int step = 1, bool useHadamard = false );
void setDistParam( DistParam &rcDP, const CPelBuf &org, const CPelBuf &cur, int bitDepth, ComponentID compID, bool useHadamard = false );
#if JVET_K0485_BIO
void setDistParam( DistParam &rcDP, const Pel* pOrg, const Pel* piRefY, int iOrgStride, int iRefStride, int bitDepth, ComponentID compID, int width, int height, int subShiftMode = 0, int step = 1, bool useHadamard = false, bool bio = false );
#else
void setDistParam( DistParam &rcDP, const Pel* pOrg, const Pel* piRefY, int iOrgStride, int iRefStride, int bitDepth, ComponentID compID, int width, int height, int subShiftMode = 0, int step = 1, bool useHadamard = false );
#endif
double getMotionLambda ( bool bIsTransquantBypass ) { return m_dLambdaMotionSAD[(bIsTransquantBypass && m_costMode==COST_MIXED_LOSSLESS_LOSSY_CODING)?1:0]; }
void selectMotionLambda ( bool bIsTransquantBypass ) { m_motionLambda = getMotionLambda( bIsTransquantBypass ); }
......
Markdown is supported
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