Commit 4a9cbaca authored by Zizheng Liu's avatar Zizheng Liu
Browse files

JCTVC-AH0024, implementation of JVET-K0390 and JVET-M0600

parent ea722e6c
......@@ -81,6 +81,11 @@
// Tool Switches - transitory (these macros are likely to be removed in future revisions)
// ====================================================================================================================
#define JVET_K0390_RATE_CTRL 1
#if JVET_K0390_RATE_CTRL
#define JVET_M0600_RATE_CTRL 1
#endif
#define DECODER_CHECK_SUBSTREAM_AND_SLICE_TRAILING_BYTES 1 ///< TODO: integrate this macro into a broader conformance checking system.
#define X0038_LAMBDA_FROM_QP_CAPABILITY 1 ///< This approach derives lambda from QP+QPoffset+QPoffset2. QPoffset2 is derived from QP+QPoffset using a linear model that is clipped between 0 and 3.
// To use this capability enable config parameter LambdaFromQpEnable
......@@ -160,7 +165,7 @@
#define FULL_NBIT 1 ///< When enabled, use distortion measure derived from all bits of source data, otherwise discard (bitDepth - 8) least-significant bits of distortion
#define RExt__HIGH_PRECISION_FORWARD_TRANSFORM 1 ///< 0 use original 6-bit transform matrices for both forward and inverse transform, 1 (default) = use original matrices for inverse transform and high precision matrices for forward transform
#else
#define FULL_NBIT 1 ///< When enabled, use distortion measure derived from all bits of source data, otherwise discard (bitDepth - 8) least-significant bits of distortion
#define FULL_NBIT 0 ///< When enabled, use distortion measure derived from all bits of source data, otherwise discard (bitDepth - 8) least-significant bits of distortion
#define RExt__HIGH_PRECISION_FORWARD_TRANSFORM 0 ///< 0 (default) use original 6-bit transform matrices for both forward and inverse transform, 1 = use original matrices for inverse transform and high precision matrices for forward transform
#endif
......
This diff is collapsed.
......@@ -86,12 +86,22 @@ struct TRCLCU
Int m_numberOfPixel;
Double m_costIntra;
Int m_targetBitsLeft;
#if JVET_K0390_RATE_CTRL
double m_actualSSE;
double m_actualMSE;
#endif
};
struct TRCParameter
{
Double m_alpha;
Double m_beta;
#if JVET_K0390_RATE_CTRL
int m_validPix;
#endif
#if JVET_M0600_RATE_CTRL
double m_skipRatio;
#endif
};
class TEncRCSeq
......@@ -195,8 +205,11 @@ public:
private:
Int xEstGOPTargetBits( TEncRCSeq* encRCSeq, Int GOPSize );
Void xCalEquaCoeff( TEncRCSeq* encRCSeq, Double* lambdaRatio, Double* equaCoeffA, Double* equaCoeffB, Int GOPSize );
#if JVET_K0390_RATE_CTRL
Double xSolveEqua(TEncRCSeq* encRCSeq, double targetBpp, double* equaCoeffA, double* equaCoeffB, int GOPSize);
#else
Double xSolveEqua( Double targetBpp, Double* equaCoeffA, Double* equaCoeffB, Int GOPSize );
#endif
public:
TEncRCSeq* getEncRCSeq() { return m_encRCSeq; }
Int getNumPic() { return m_numPic;}
......@@ -235,8 +248,11 @@ public:
Double getLCUEstLambdaAndQP(Double bpp, Int clipPicQP, Int *estQP);
Double getLCUEstLambda( Double bpp );
Int getLCUEstQP( Double lambda, Int clipPicQP );
#if JVET_M0600_RATE_CTRL
void updateAfterCTU( Int LCUIdx, Int bits, Int QP, Double lambda, Double skipRatio, Bool updateLCUParameter = true);
#else
Void updateAfterCTU( Int LCUIdx, Int bits, Int QP, Double lambda, Bool updateLCUParameter = true );
#endif
Void updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda, SliceType eSliceType);
Void addToPictureLsit( list<TEncRCPic*>& listPreviousPictures );
......@@ -279,6 +295,11 @@ public:
Double getPicEstLambda() { return m_estPicLambda; }
Void setPicEstLambda( Double lambda ) { m_picLambda = lambda; }
#if JVET_K0390_RATE_CTRL
double getPicMSE() { return m_picMSE; }
void setPicMSE(double avgMSE) { m_picMSE = avgMSE; }
#endif
private:
TEncRCSeq* m_encRCSeq;
TEncRCGOP* m_encRCGOP;
......@@ -303,6 +324,10 @@ private:
Int m_picActualBits; // the whole picture, including header
Int m_picQP; // in integer form
Double m_picLambda;
#if JVET_K0390_RATE_CTRL
Double m_picMSE;
Int m_validPixelsInPic;
#endif
};
class TEncRateCtrl
......
......@@ -934,6 +934,16 @@ Void TEncSlice::compressSlice( TComPic* pcPic, const Bool bCompressEntireSlice,
Double actualLambda = m_pcRdCost->getLambda();
Int actualBits = pCtu->getTotalBits();
Int numberOfEffectivePixels = 0;
#if JVET_M0600_RATE_CTRL
Int numberOfSkipPixel = 0;
for (Int idx = 0; idx < pcPic->getNumPartitionsInCtu(); idx++)
{
numberOfSkipPixel += 16 * pCtu->isSkipped(idx);
}
#endif
for ( Int idx = 0; idx < pcPic->getNumPartitionsInCtu(); idx++ )
{
if ( pCtu->getPredictionMode( idx ) != NUMBER_OF_PREDICTION_MODES && ( !pCtu->isSkipped( idx ) ) )
......@@ -943,6 +953,10 @@ Void TEncSlice::compressSlice( TComPic* pcPic, const Bool bCompressEntireSlice,
}
}
#if JVET_M0600_RATE_CTRL
Double skipRatio = (Double)numberOfSkipPixel / m_pcRateCtrl->getRCPic()->getLCU(ctuTsAddr).m_numberOfPixel;
#endif
if ( numberOfEffectivePixels == 0 )
{
actualQP = g_RCInvalidQPValue;
......@@ -951,9 +965,17 @@ Void TEncSlice::compressSlice( TComPic* pcPic, const Bool bCompressEntireSlice,
{
actualQP = pCtu->getQP( 0 );
}
#if JVET_K0390_RATE_CTRL
m_pcRateCtrl->getRCPic()->getLCU(ctuTsAddr).m_actualMSE = (double)pCtu->getTotalDistortion() / (double)m_pcRateCtrl->getRCPic()->getLCU(ctuTsAddr).m_numberOfPixel;
#endif
m_pcRdCost->setLambda(oldLambda, pcSlice->getSPS()->getBitDepths());
#if JVET_M0600_RATE_CTRL
m_pcRateCtrl->getRCPic()->updateAfterCTU(m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, skipRatio,
pCtu->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC());
#else
m_pcRateCtrl->getRCPic()->updateAfterCTU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda,
pCtu->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() );
#endif
}
m_uiPicTotalBits += pCtu->getTotalBits();
......@@ -961,6 +983,7 @@ Void TEncSlice::compressSlice( TComPic* pcPic, const Bool bCompressEntireSlice,
m_uiPicDist += pCtu->getTotalDistortion();
}
// store context state at the end of this slice-segment, in case the next slice is a dependent slice and continues using the CABAC contexts.
if( pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag() )
{
......
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