Commit 04f98473 authored by Kenneth Andersson's avatar Kenneth Andersson

JVET-T0064 Addition of ALF filter strength control to VTM

parent a46a3c30
......@@ -88,6 +88,7 @@ LMChroma : 1 # use CCLM only
DepQuant : 1
IMV : 1
ALF : 1
ALFStrength : 1.0
IBC : 0 # turned off in CTC
AllowDisFracMMVD : 1
AffineAmvr : 0
......
......@@ -111,6 +111,7 @@ LMChroma : 1 # use CCLM only
DepQuant : 1
IMV : 1
ALF : 1
ALFStrength : 1.0
CIIP : 1
IBC : 0 # turned off in CTC
AllowDisFracMMVD : 1
......
......@@ -112,6 +112,7 @@ LMChroma : 1 # use CCLM only
DepQuant : 1
IMV : 1
ALF : 1
ALFStrength : 1.0
BCW : 1
BcwFast : 1
CIIP : 1
......
......@@ -140,6 +140,7 @@ LMChroma : 1 # use CCLM only
DepQuant : 1
IMV : 1
ALF : 1
ALFStrength : 1.0
BCW : 1
BcwFast : 1
BIO : 1
......
......@@ -124,6 +124,7 @@ LMChroma : 1 # use CCLM only
DepQuant : 1
IMV : 1
ALF : 1
ALFStrength : 1.0
BCW : 1
BcwFast : 1
BIO : 1
......
......@@ -2888,6 +2888,12 @@ switched at CTB level. Set to 1 to disable alternative chroma filters.
Value shall be in the range 1..8.
\\
\Option{ALFStrength} &
%\ShortOption{\None} &
\Default{1.0} &
Enables control of ALF filter strength. The parameter scales the magnitudes of the ALF filter coefficients for both luma and chroma.
\\
\Option{CCALF} &
%\ShortOption{\None} &
\Default{true} &
......
......@@ -1048,6 +1048,9 @@ void EncApp::xInitLibCfg()
m_cEncLib.setForceSingleSplitThread ( m_forceSplitSequential );
#endif
m_cEncLib.setUseALF ( m_alf );
#if JVET_T0064
m_cEncLib.setALFStrength (m_alfStrength);
#endif
m_cEncLib.setUseCCALF ( m_ccalf );
m_cEncLib.setCCALFQpThreshold ( m_ccalfQpThreshold );
m_cEncLib.setLmcs ( m_lmcsEnabled );
......
......@@ -1403,6 +1403,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
("DebugCTU", m_debugCTU, -1, "If DebugBitstream is present, load frames up to this POC from this bitstream. Starting with DebugPOC-frame at CTUline containin debug CTU.")
("EnsureWppBitEqual", m_ensureWppBitEqual, false, "Ensure the results are equal to results with WPP-style parallelism, even if WPP is off")
( "ALF", m_alf, true, "Adaptive Loop Filter\n" )
#if JVET_T0064
("ALFStrength", m_alfStrength, 1.0, "Adaptive Loop Filter strength. The parameter scales the magnitudes of the ALF filter coefficients for both luma and chroma.")
#endif
( "CCALF", m_ccalf, true, "Cross-component Adaptive Loop Filter" )
( "CCALFQpTh", m_ccalfQpThreshold, 37, "QP threshold above which encoder reduces CCALF usage")
( "RPR", m_rprEnabledFlag, true, "Reference Sample Resolution" )
......
......@@ -694,6 +694,9 @@ protected:
bool m_forceDecodeBitstream1;
bool m_alf; ///< Adaptive Loop Filter
#if JVET_T0064
double m_alfStrength;
#endif
bool m_ccalf;
int m_ccalfQpThreshold;
......
......@@ -69,6 +69,8 @@
#define JVET_S0175_ASPECT5 1 // use u(8) instead of u(4) for (ffi_)display_elemental_periods_minus1 and pt_display_elemental_periods_minus1
#define JVET_S0175_ASPECT6 1 // The general_nal_hrd_params_present_flag and general_vcl_hrd_params_present_flag are allowed to both be equal to 0
#define JVET_R0046_IRAP_ASPECT2 1 // Add a constraint on an ILRP being either an IRAP picture or having TemporalId less than or equal to Max (0, vps_max_tid_il_ref_pics_plus1[ refPicVpsLayerId ] - 1 )
#define JVET_T0064 1 // JVET-T0064: control of filter strength for ALF
//########### place macros to be be kept below this line ###############
#define JVET_S0257_DUMP_360SEI_MESSAGE 1 // Software support of 360 SEI messages
......
......@@ -1834,7 +1834,12 @@ double EncAdaptiveLoopFilter::deriveCoeffQuant( int *filterClipp, int *filterCoe
filterCoeffQuant[numCoeff - 1] = 0;
int modified=1;
#if JVET_T0064
if( m_encCfg->getALFStrength() != 1.0 )
{
modified = 0;
}
#endif
double errRef=cov.calcErrorForCoeffs( filterClipp, filterCoeffQuant, numCoeff, bitDepth );
while( modified )
{
......@@ -1878,7 +1883,11 @@ void EncAdaptiveLoopFilter::roundFiltCoeff( int *filterCoeffQuant, double *filte
for( int i = 0; i < numCoeff; i++ )
{
int sign = filterCoeff[i] > 0 ? 1 : -1;
#if JVET_T0064
filterCoeffQuant[i] = int((filterCoeff[i] * m_encCfg->getALFStrength()) * sign * factor + 0.5) * sign;
#else
filterCoeffQuant[i] = int( filterCoeff[i] * sign * factor + 0.5 ) * sign;
#endif
}
}
......@@ -2721,7 +2730,16 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfPar
double costOn = MAX_DOUBLE;
ctxTempStart = AlfCtx(m_CABACEstimator->getCtx());
int iBestFilterSetIdx = 0;
#if JVET_T0064
int firstFilterSetIdx = 0;
if (m_encCfg->getALFStrength() != 1.0)
{
firstFilterSetIdx = NUM_FIXED_FILTER_SETS;
}
for (int filterSetIdx = firstFilterSetIdx; filterSetIdx < numFilterSet; filterSetIdx++)
#else
for (int filterSetIdx = 0; filterSetIdx < numFilterSet; filterSetIdx++)
#endif
{
//rate
m_CABACEstimator->getCtx() = AlfCtx(ctxTempStart);
......
......@@ -738,6 +738,9 @@ protected:
#endif
bool m_alf; ///< Adaptive Loop Filter
#if JVET_T0064
double m_alfStrength;
#endif
bool m_ccalf;
int m_ccalfQpThreshold;
#if JVET_O0756_CALCULATE_HDRMETRICS
......@@ -1923,6 +1926,10 @@ public:
#endif
void setUseALF( bool b ) { m_alf = b; }
bool getUseALF() const { return m_alf; }
#if JVET_T0064
void setALFStrength( double s) { m_alfStrength = s; }
double getALFStrength() const { return m_alfStrength; }
#endif
void setUseCCALF( bool b ) { m_ccalf = b; }
bool getUseCCALF() const { return m_ccalf; }
void setCCALFQpThreshold( int b ) { m_ccalfQpThreshold = b; }
......
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