Commit 22c0feeb authored by Karsten Suehring's avatar Karsten Suehring
Browse files

Merge branch 'JVET-Y0105' into 'master'

JVET-Y0105: An improved VVC rate control scheme

See merge request !57
parents ef7c6230 36345215
Pipeline #7104 passed with stage
in 10 minutes and 8 seconds
......@@ -53,6 +53,9 @@
#define JVET_V0078 1 // JVET-V0078: QP control for very smooth blocks
#define JVET_Y0105_SW_AND_QDF 1 // An adaptive smooth window (SW) size and extension of quality dependency factor (QDF) to low frame rate in rate control
// ====================================================================================================================
// Debugging
// ====================================================================================================================
......
......@@ -50,6 +50,9 @@ TEncRCSeq::TEncRCSeq()
m_frameRate = 0;
m_targetBits = 0;
m_GOPSize = 0;
#if JVET_Y0105_SW_AND_QDF
m_intraPeriod = 0;
#endif
m_picWidth = 0;
m_picHeight = 0;
m_LCUWidth = 0;
......@@ -74,13 +77,20 @@ TEncRCSeq::~TEncRCSeq()
destroy();
}
#if JVET_Y0105_SW_AND_QDF
Void TEncRCSeq::create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int intraPeriod, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel, Int adaptiveBit )
#else
Void TEncRCSeq::create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel, Int adaptiveBit )
#endif
{
destroy();
m_totalFrames = totalFrames;
m_targetRate = targetBitrate;
m_frameRate = frameRate;
m_GOPSize = GOPSize;
#if JVET_Y0105_SW_AND_QDF
m_intraPeriod = intraPeriod;
#endif
m_picWidth = picWidth;
m_picHeight = picHeight;
m_LCUWidth = LCUWidth;
......@@ -315,12 +325,22 @@ TEncRCGOP::~TEncRCGOP()
destroy();
}
#if JVET_Y0105_SW_AND_QDF
Void TEncRCGOP::create( TEncRCSeq* encRCSeq, Int numPic, Bool useAdaptiveBitsRatio )
#else
Void TEncRCGOP::create( TEncRCSeq* encRCSeq, Int numPic )
#endif
{
destroy();
Int targetBits = xEstGOPTargetBits( encRCSeq, numPic );
#if JVET_Y0105_SW_AND_QDF
if ( useAdaptiveBitsRatio )
#else
if ( encRCSeq->getAdaptiveBits() > 0 && encRCSeq->getLastLambda() > 0.1 )
#endif
{
Double targetBpp = (Double)targetBits / encRCSeq->getNumPixel();
Double basicLambda = 0.0;
......@@ -554,7 +574,11 @@ Void TEncRCGOP::updateAfterPicture( Int bitsCost )
Int TEncRCGOP::xEstGOPTargetBits( TEncRCSeq* encRCSeq, Int GOPSize )
{
#if JVET_Y0105_SW_AND_QDF
Int realInfluencePicture = min( g_RCSmoothWindowSizeAlpha * GOPSize / max(encRCSeq->getIntraPeriod(), 32) + g_RCSmoothWindowSizeBeta, encRCSeq->getFramesLeft() );
#else
Int realInfluencePicture = min( g_RCSmoothWindowSize, encRCSeq->getFramesLeft() );
#endif
Int averageTargetBitsPerPic = (Int)( encRCSeq->getTargetBits() / encRCSeq->getTotalFrames() );
Int currentTargetBitsPerPic = (Int)( ( encRCSeq->getBitsLeft() - averageTargetBitsPerPic * (encRCSeq->getFramesLeft() - realInfluencePicture) ) / realInfluencePicture );
Int targetBits = currentTargetBitsPerPic * GOPSize;
......@@ -1509,7 +1533,11 @@ Void TEncRateCtrl::destroy()
}
}
#if JVET_Y0105_SW_AND_QDF
Void TEncRateCtrl::init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int intraPeriod, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP] )
#else
Void TEncRateCtrl::init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP] )
#endif
{
destroy();
......@@ -1822,7 +1850,12 @@ Void TEncRateCtrl::init( Int totalFrames, Int targetBitrate, Int frameRate, Int
#endif
m_encRCSeq = new TEncRCSeq;
#if JVET_Y0105_SW_AND_QDF
m_encRCSeq->create( totalFrames, targetBitrate, frameRate, GOPSize, intraPeriod, picWidth, picHeight, LCUWidth, LCUHeight, numberOfLevel, useLCUSeparateModel, adaptiveBit );
#else
m_encRCSeq->create( totalFrames, targetBitrate, frameRate, GOPSize, picWidth, picHeight, LCUWidth, LCUHeight, numberOfLevel, useLCUSeparateModel, adaptiveBit );
#endif
m_encRCSeq->initBitsRatio( bitsRatio );
m_encRCSeq->initGOPID2Level( GOPID2Level );
m_encRCSeq->initPicPara();
......@@ -1848,7 +1881,12 @@ Void TEncRateCtrl::initRCPic( Int frameLevel )
Void TEncRateCtrl::initRCGOP( Int numberOfPictures )
{
m_encRCGOP = new TEncRCGOP;
#if JVET_Y0105_SW_AND_QDF
bool useAdaptiveBitsRatio = ( m_encRCSeq->getAdaptiveBits() > 0 ) && ( m_listRCPictures.size() >= m_encRCSeq->getGOPSize() );
m_encRCGOP->create( m_encRCSeq, numberOfPictures, useAdaptiveBitsRatio);
#else
m_encRCGOP->create( m_encRCSeq, numberOfPictures );
#endif
}
Int TEncRateCtrl::updateCpbState(Int actualBits)
......
......@@ -59,7 +59,12 @@ using namespace std;
#include <cassert>
const Int g_RCInvalidQPValue = -999;
const Int g_RCSmoothWindowSize = 40;
#if JVET_Y0105_SW_AND_QDF
const int g_RCSmoothWindowSizeAlpha = 20;
const int g_RCSmoothWindowSizeBeta = 60;
#else
const int g_RCSmoothWindowSize = 40;
#endif
const Int g_RCMaxPicListSize = 32;
const Double g_RCWeightPicTargetBitInGOP = 0.9;
const Double g_RCWeightPicRargetBitInBuffer = 1.0 - g_RCWeightPicTargetBitInGOP;
......@@ -114,7 +119,11 @@ public:
~TEncRCSeq();
public:
#if JVET_Y0105_SW_AND_QDF
Void create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int intraPeriod, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel, Int adaptiveBit );
#else
Void create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel, Int adaptiveBit );
#endif
Void destroy();
Void initBitsRatio( Int bitsRatio[] );
Void initGOPID2Level( Int GOPID2Level[] );
......@@ -128,6 +137,9 @@ public:
Int getTargetRate() { return m_targetRate; }
Int getFrameRate() { return m_frameRate; }
Int getGOPSize() { return m_GOPSize; }
#if JVET_Y0105_SW_AND_QDF
Int getIntraPeriod() { return m_intraPeriod; }
#endif
Int getPicWidth() { return m_picWidth; }
Int getPicHeight() { return m_picHeight; }
Int getLCUWidth() { return m_LCUWidth; }
......@@ -168,6 +180,9 @@ private:
Int m_targetRate;
Int m_frameRate;
Int m_GOPSize;
#if JVET_Y0105_SW_AND_QDF
Int m_intraPeriod;
#endif
Int m_picWidth;
Int m_picHeight;
Int m_LCUWidth;
......@@ -201,7 +216,11 @@ public:
~TEncRCGOP();
public:
#if JVET_Y0105_SW_AND_QDF
Void create( TEncRCSeq* encRCSeq, Int numPic, bool useAdaptiveBitsRatio );
#else
Void create( TEncRCSeq* encRCSeq, Int numPic );
#endif
Void destroy();
Void updateAfterPicture( Int bitsCost );
......@@ -340,7 +359,11 @@ public:
~TEncRateCtrl();
public:
#if JVET_Y0105_SW_AND_QDF
Void init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int intraPeriod, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP] );
#else
Void init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP] );
#endif
Void destroy();
Void initRCPic( Int frameLevel );
Void initRCGOP( Int numberOfPictures );
......
......@@ -111,9 +111,15 @@ Void TEncTop::create ()
if ( m_RCEnableRateControl )
{
#if JVET_Y0105_SW_AND_QDF
m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, (Int)( (Double)m_iFrameRate/m_temporalSubsampleRatio + 0.5), m_iGOPSize, m_uiIntraPeriod, m_iSourceWidth, m_iSourceHeight,
m_maxCUWidth, m_maxCUHeight,m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList );
#else
m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, (Int)( (Double)m_iFrameRate/m_temporalSubsampleRatio + 0.5), m_iGOPSize, m_iSourceWidth, m_iSourceHeight,
m_maxCUWidth, m_maxCUHeight,m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList );
#endif
}
m_pppcRDSbacCoder = new TEncSbac** [m_maxTotalCUDepth+1];
#if FAST_BIT_EST
......
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