Commit 7f7b6d26 authored by Karl Sharman's avatar Karl Sharman
Browse files

remove macro X0038_LAMBDA_FROM_QP_CAPABILITY

parent 09ecac62
......@@ -169,10 +169,8 @@ std::istringstream &operator>>(std::istringstream &in, GOPEntry &entry) //in
in>>entry.m_sliceType;
in>>entry.m_POC;
in>>entry.m_QPOffset;
#if X0038_LAMBDA_FROM_QP_CAPABILITY
in>>entry.m_QPOffsetModelOffset;
in>>entry.m_QPOffsetModelScale;
#endif
in>>entry.m_CbQPoffset;
in>>entry.m_CrQPoffset;
in>>entry.m_QPFactor;
......@@ -902,10 +900,8 @@ Bool TAppEncCfg::parseCfg( Int argc, TChar* argv[] )
/* Quantization parameters */
("QP,q", m_iQP, 30, "Qp value")
("QPIncrementFrame,-qpif", m_qpIncrementAtSourceFrame, OptionalValue<UInt>(), "If a source file frame number is specified, the internal QP will be incremented for all POCs associated with source frames >= frame number. If empty, do not increment.")
#if X0038_LAMBDA_FROM_QP_CAPABILITY
("IntraQPOffset", m_intraQPOffset, 0, "Qp offset value for intra slice, typically determined based on GOP size")
("LambdaFromQpEnable", m_lambdaFromQPEnable, false, "Enable flag for derivation of lambda from QP")
#endif
("DeltaQpRD,-dqr", m_uiDeltaQpRD, 0u, "max dQp offset for slice")
("MaxDeltaQP,d", m_iMaxDeltaQP, 0, "max dQp offset for block")
("MaxCuDQPDepth,-dqd", m_iMaxCuDQPDepth, 0, "max depth for a minimum CuDQP")
......
......@@ -161,10 +161,8 @@ protected:
// coding quality
OptionalValue<UInt> m_qpIncrementAtSourceFrame; ///< Optional source frame number at which all subsequent frames are to use an increased internal QP.
Int m_iQP; ///< QP value of key-picture (integer)
#if X0038_LAMBDA_FROM_QP_CAPABILITY
Int m_intraQPOffset; ///< QP offset for intra slice (integer)
Bool m_lambdaFromQPEnable; ///< enable flag for QP:lambda fix
#endif
std::string m_dQPFileName; ///< QP offset for each slice (initialized from external file)
Int* m_aidQP; ///< array of slice QP values
Int m_iMaxDeltaQP; ///< max. |delta QP|
......
......@@ -143,10 +143,8 @@ Void TAppEncTop::xInitLibCfg()
m_cTEncTop.setQP ( m_iQP );
#if X0038_LAMBDA_FROM_QP_CAPABILITY
m_cTEncTop.setIntraQPOffset ( m_intraQPOffset );
m_cTEncTop.setLambdaFromQPEnable ( m_lambdaFromQPEnable );
#endif
m_cTEncTop.setPad ( m_aiPad );
m_cTEncTop.setAccessUnitDelimiter ( m_AccessUnitDelimiter );
......@@ -196,11 +194,7 @@ Void TAppEncTop::xInitLibCfg()
//====== Tool list ========
m_cTEncTop.setLumaLevelToDeltaQPControls ( m_lumaLevelToDeltaQPMapping );
#if X0038_LAMBDA_FROM_QP_CAPABILITY
m_cTEncTop.setDeltaQpRD( (m_costMode==COST_LOSSLESS_CODING) ? 0 : m_uiDeltaQpRD );
#else
m_cTEncTop.setDeltaQpRD ( m_uiDeltaQpRD );
#endif
m_cTEncTop.setFastDeltaQp ( m_bFastDeltaQP );
m_cTEncTop.setUseASR ( m_bUseASR );
m_cTEncTop.setUseHADME ( m_bUseHADME );
......
......@@ -77,6 +77,7 @@
#define PRINT_RPS_INFO 0 ///< Enable/disable the printing of bits used to send the RPS.
#define MCTS_EXTRACTION 1 ///< Additional project for MCTS Extraction as in JCTVC-AC1005
// ====================================================================================================================
// Tool Switches - transitory (these macros are likely to be removed in future revisions)
// ====================================================================================================================
......@@ -85,26 +86,10 @@
#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
#ifndef EXTENSION_360_VIDEO
#define EXTENSION_360_VIDEO 0 ///< extension for 360/spherical video coding support; this macro should be controlled by makefile, as it would be used to control whether the library is built and linked
#endif
#define MCTS_ENC_CHECK 1 ///< Temporal MCTS encoder constraint and decoder checks. Also requires SEITMCTSTileConstraint to be enabled to enforce constraint
#define SHUTTER_INTERVAL_SEI_MESSAGE 1 ///< support for shutter interval SEI message
#define SEI_ENCODER_CONTROL 1 ///< add encoder control for the following SEI: film grain characteristics, content light level, ambient viewing environment
#define DPB_ENCODER_USAGE_CHECK 1 ///< Adds DPB encoder usage check.
// ====================================================================================================================
......@@ -113,6 +98,10 @@
// Please also refer to "TDecConformance.h" for DECODER_PARTIAL_CONFORMANCE_CHECK
#ifndef EXTENSION_360_VIDEO
#define EXTENSION_360_VIDEO 0 ///< extension for 360/spherical video coding support; this macro should be controlled by makefile, as it would be used to control whether the library is built and linked
#endif
#define REDUCED_ENCODER_MEMORY 1 ///< When 1, the encoder will allocate TComPic memory when required and release it when no longer required.
#define ADAPTIVE_QP_SELECTION 1 ///< G382: Adaptive reconstruction levels, non-normative part for adaptive QP selection
......
......@@ -50,10 +50,8 @@ struct GOPEntry
{
Int m_POC;
Int m_QPOffset;
#if X0038_LAMBDA_FROM_QP_CAPABILITY
Double m_QPOffsetModelOffset;
Double m_QPOffsetModelScale;
#endif
Int m_CbQPoffset;
Int m_CrQPoffset;
Double m_QPFactor;
......@@ -74,10 +72,8 @@ struct GOPEntry
GOPEntry()
: m_POC(-1)
, m_QPOffset(0)
#if X0038_LAMBDA_FROM_QP_CAPABILITY
, m_QPOffsetModelOffset(0)
, m_QPOffsetModelScale(0)
#endif
, m_CbQPoffset(0)
, m_CrQPoffset(0)
, m_QPFactor(0)
......@@ -177,10 +173,8 @@ protected:
Int m_numReorderPics[MAX_TLAYER];
Int m_iQP; // if (AdaptiveQP == OFF)
#if X0038_LAMBDA_FROM_QP_CAPABILITY
Int m_intraQPOffset; ///< QP offset for intra slice (integer)
Int m_lambdaFromQPEnable; ///< enable lambda derivation from QP
#endif
Int m_aiPad[2];
Bool m_AccessUnitDelimiter; ///< add Access Unit Delimiter NAL units
......@@ -596,10 +590,8 @@ public:
Void setNumReorderPics ( Int i, UInt tlayer ) { m_numReorderPics[tlayer] = i; }
Void setQP ( Int i ) { m_iQP = i; }
#if X0038_LAMBDA_FROM_QP_CAPABILITY
Void setIntraQPOffset ( Int i ) { m_intraQPOffset = i; }
Void setLambdaFromQPEnable ( Bool b ) { m_lambdaFromQPEnable = b; }
#endif
Void setPad ( Int* iPad ) { for ( Int i = 0; i < 2; i++ ) m_aiPad[i] = iPad[i]; }
Int getMaxRefPicNum () { return m_iMaxRefPicNum; }
......@@ -695,16 +687,12 @@ public:
Int getGOPSize () { return m_iGOPSize; }
Int getMaxDecPicBuffering (UInt tlayer) { return m_maxDecPicBuffering[tlayer]; }
Int getNumReorderPics (UInt tlayer) { return m_numReorderPics[tlayer]; }
#if X0038_LAMBDA_FROM_QP_CAPABILITY
Int getIntraQPOffset () const { return m_intraQPOffset; }
Int getLambdaFromQPEnable () const { return m_lambdaFromQPEnable; }
protected:
Int getBaseQP () const { return m_iQP; } // public should use getQPForPicture.
public:
Int getQPForPicture (const UInt gopIndex, const TComSlice *pSlice) const; // Function actually defined in TEncTop.cpp
#else
Int getQP () { return m_iQP; }
#endif
Int getPad ( Int i ) { assert (i < 2 ); return m_aiPad[i]; }
Bool getAccessUnitDelimiter() const { return m_AccessUnitDelimiter; }
......
......@@ -1134,7 +1134,6 @@ Int EfficientFieldIRAPMapping::restoreGOPid(const Int GOPid)
}
#if X0038_LAMBDA_FROM_QP_CAPABILITY
static UInt calculateCollocatedFromL0Flag(const TComSlice *pSlice)
{
const Int refIdx = 0; // Zero always assumed
......@@ -1142,56 +1141,6 @@ static UInt calculateCollocatedFromL0Flag(const TComSlice *pSlice)
const TComPic *refPicL1 = pSlice->getRefPic(REF_PIC_LIST_1, refIdx);
return refPicL0->getSlice(0)->getSliceQp() > refPicL1->getSlice(0)->getSliceQp();
}
#else
static UInt calculateCollocatedFromL1Flag(TEncCfg *pCfg, const Int GOPid, const Int gopSize)
{
Int iCloseLeft=1, iCloseRight=-1;
for(Int i = 0; i<pCfg->getGOPEntry(GOPid).m_numRefPics; i++)
{
Int iRef = pCfg->getGOPEntry(GOPid).m_referencePics[i];
if(iRef>0&&(iRef<iCloseRight||iCloseRight==-1))
{
iCloseRight=iRef;
}
else if(iRef<0&&(iRef>iCloseLeft||iCloseLeft==1))
{
iCloseLeft=iRef;
}
}
if(iCloseRight>-1)
{
iCloseRight=iCloseRight+pCfg->getGOPEntry(GOPid).m_POC-1;
}
if(iCloseLeft<1)
{
iCloseLeft=iCloseLeft+pCfg->getGOPEntry(GOPid).m_POC-1;
while(iCloseLeft<0)
{
iCloseLeft+=gopSize;
}
}
Int iLeftQP=0, iRightQP=0;
for(Int i=0; i<gopSize; i++)
{
if(pCfg->getGOPEntry(i).m_POC==(iCloseLeft%gopSize)+1)
{
iLeftQP= pCfg->getGOPEntry(i).m_QPOffset;
}
if (pCfg->getGOPEntry(i).m_POC==(iCloseRight%gopSize)+1)
{
iRightQP=pCfg->getGOPEntry(i).m_QPOffset;
}
}
if(iCloseRight>-1&&iRightQP<iLeftQP)
{
return 0;
}
else
{
return 1;
}
}
#endif
static Void
......@@ -1275,9 +1224,6 @@ Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rc
//-- For time output for each slice
clock_t iBeforeTime = clock();
#if !X0038_LAMBDA_FROM_QP_CAPABILITY
UInt uiColDir = calculateCollocatedFromL1Flag(m_pcCfg, iGOPid, m_iGopSize);
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////// Initial to start encoding
Int iTimeOffset;
......@@ -1511,12 +1457,8 @@ Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rc
if (pcSlice->getSliceType() == B_SLICE)
{
#if X0038_LAMBDA_FROM_QP_CAPABILITY
const UInt uiColFromL0 = calculateCollocatedFromL0Flag(pcSlice);
pcSlice->setColFromL0Flag(uiColFromL0);
#else
pcSlice->setColFromL0Flag(1-uiColDir);
#endif
Bool bLowDelay = true;
Int iCurrPOC = pcSlice->getPOC();
Int iRefIdx = 0;
......@@ -1543,9 +1485,6 @@ Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rc
pcSlice->setCheckLDC(true);
}
#if !X0038_LAMBDA_FROM_QP_CAPABILITY
uiColDir = 1-uiColDir;
#endif
//-------------------------------------------------------------
pcSlice->setRefPOCList();
......
......@@ -251,39 +251,13 @@ Void TEncSlice::initEncSlice( TComPic* pcPic, const Int pocLast, const Int pocCu
// QP setting
// ------------------------------------------------------------------------------------------------------------------
#if X0038_LAMBDA_FROM_QP_CAPABILITY
dQP = m_pcCfg->getQPForPicture(iGOPid, rpcSlice);
#else
dQP = m_pcCfg->getQP();
if(eSliceType!=I_SLICE)
{
if (!(( m_pcCfg->getMaxDeltaQP() == 0) && (!m_pcCfg->getLumaLevelToDeltaQPMapping().isEnabled()) && (dQP == -rpcSlice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA) ) && (rpcSlice->getPPS()->getTransquantBypassEnabledFlag())))
{
dQP += m_pcCfg->getGOPEntry(iGOPid).m_QPOffset;
}
}
// modify QP
const Int* pdQPs = m_pcCfg->getdQPs();
if ( pdQPs )
{
dQP += pdQPs[ rpcSlice->getPOC() ];
}
if (m_pcCfg->getCostMode()==COST_LOSSLESS_CODING)
{
dQP=LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP;
m_pcCfg->setDeltaQpRD(0);
}
#endif
// ------------------------------------------------------------------------------------------------------------------
// Lambda computation
// ------------------------------------------------------------------------------------------------------------------
#if X0038_LAMBDA_FROM_QP_CAPABILITY
const Int temporalId=m_pcCfg->getGOPEntry(iGOPid).m_temporalId;
#endif
Int iQP;
Double dOrigQP = dQP;
......@@ -304,10 +278,6 @@ Void TEncSlice::initEncSlice( TComPic* pcPic, const Int pocLast, const Int pocCu
dQP = m_vdRdPicQp [0];
iQP = m_viRdPicQp [0];
#if !X0038_LAMBDA_FROM_QP_CAPABILITY
const Int temporalId=m_pcCfg->getGOPEntry(iGOPid).m_temporalId;
const std::vector<Double> &intraLambdaModifiers=m_pcCfg->getIntraLambdaModifier();
#endif
if(rpcSlice->getPPS()->getSliceChromaQpFlag())
{
......@@ -328,19 +298,6 @@ Void TEncSlice::initEncSlice( TComPic* pcPic, const Int pocLast, const Int pocCu
rpcSlice->setSliceChromaQpDelta( COMPONENT_Cr, 0 );
}
#if !X0038_LAMBDA_FROM_QP_CAPABILITY
Double lambdaModifier;
if( rpcSlice->getSliceType( ) != I_SLICE || intraLambdaModifiers.empty())
{
lambdaModifier = m_pcCfg->getLambdaModifier( temporalId );
}
else
{
lambdaModifier = intraLambdaModifiers[ (temporalId < intraLambdaModifiers.size()) ? temporalId : (intraLambdaModifiers.size()-1) ];
}
dLambda *= lambdaModifier;
#endif
setUpLambda(rpcSlice, dLambda, iQP);
......@@ -441,10 +398,8 @@ Double TEncSlice::calculateLambda( const TComSlice* slice,
const Bool isField = slice->getPic()->isField();
const Int NumberBFrames = ( m_pcCfg->getGOPSize() - 1 );
const Int SHIFT_QP = 12;
#if X0038_LAMBDA_FROM_QP_CAPABILITY
const Int temporalId=m_pcCfg->getGOPEntry(GOPid).m_temporalId;
const std::vector<Double> &intraLambdaModifiers=m_pcCfg->getIntraLambdaModifier();
#endif
#if FULL_NBIT
Int bitdepth_luma_qp_scale = 6 * (slice->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 8);
......@@ -462,35 +417,25 @@ Double TEncSlice::calculateLambda( const TComSlice* slice,
}
else
{
#if X0038_LAMBDA_FROM_QP_CAPABILITY
if(m_pcCfg->getLambdaFromQPEnable())
{
dQPFactor=0.57;
}
else
{
#endif
Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)(isField ? NumberBFrames/2 : NumberBFrames) );
dQPFactor=0.57*dLambda_scale;
#if X0038_LAMBDA_FROM_QP_CAPABILITY
}
#endif
}
}
#if X0038_LAMBDA_FROM_QP_CAPABILITY
else if( m_pcCfg->getLambdaFromQPEnable() )
{
dQPFactor=0.57;
}
#endif
Double dLambda = dQPFactor*pow( 2.0, qp_temp/3.0 );
#if X0038_LAMBDA_FROM_QP_CAPABILITY
if( !(m_pcCfg->getLambdaFromQPEnable()) && depth>0 )
#else
if ( depth>0 )
#endif
{
#if FULL_NBIT
Double qp_temp_ref_orig = refQP - SHIFT_QP;
......@@ -507,7 +452,6 @@ Double TEncSlice::calculateLambda( const TComSlice* slice,
dLambda *= 0.95;
}
#if X0038_LAMBDA_FROM_QP_CAPABILITY
Double lambdaModifier;
if( eSliceType != I_SLICE || intraLambdaModifiers.empty())
{
......@@ -518,7 +462,6 @@ Double TEncSlice::calculateLambda( const TComSlice* slice,
lambdaModifier = intraLambdaModifiers[ (temporalId < intraLambdaModifiers.size()) ? temporalId : (intraLambdaModifiers.size()-1) ];
}
dLambda *= lambdaModifier;
#endif
iQP = max( -slice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );
......
......@@ -1386,7 +1386,6 @@ Bool TEncTop::SPSNeedsWriting(Int spsId)
return bChanged;
}
#if X0038_LAMBDA_FROM_QP_CAPABILITY
Int TEncCfg::getQPForPicture(const UInt gopIndex, const TComSlice *pSlice) const
{
const Int lumaQpBDOffset = pSlice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA);
......@@ -1433,6 +1432,5 @@ Int TEncCfg::getQPForPicture(const UInt gopIndex, const TComSlice *pSlice) const
qp = Clip3( -lumaQpBDOffset, MAX_QP, qp );
return qp;
}
#endif
//! \}
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