Commit 77c473d3 authored by Frank Bossen's avatar Frank Bossen

Merge branch 'JVET-T0064' into 'master'

JVET-T0064: Addition of ALF filter strength control to VTM

See merge request !1918
parents 34509dc6 b44426de
Pipeline #5939 passed with stage
in 14 minutes and 20 seconds
......@@ -110,7 +110,9 @@ FastLFNST : 1
# Encoder optimization tools
AffineAmvrEncOpt : 0
ALFStrength : 1.0
ALFAllowPredefinedFilters : 1
CCALFStrength : 1.0
### DO NOT ADD ANYTHING BELOW THIS LINE ###
### DO NOT DELETE THE EMPTY LINE BELOW ###
......
......@@ -136,6 +136,9 @@ FastLocalDualTreeMode : 2
# Encoder optimization tools
AffineAmvrEncOpt : 0
MmvdDisNum : 6
ALFStrength : 1.0
ALFAllowPredefinedFilters : 1
CCALFStrength : 1.0
### DO NOT ADD ANYTHING BELOW THIS LINE ###
### DO NOT DELETE THE EMPTY LINE BELOW ###
......
......@@ -140,6 +140,9 @@ FastLocalDualTreeMode : 2
# Encoder optimization tools
AffineAmvrEncOpt : 0
MmvdDisNum : 6
ALFStrength : 1.0
ALFAllowPredefinedFilters : 1
CCALFStrength : 1.0
### DO NOT ADD ANYTHING BELOW THIS LINE ###
### DO NOT DELETE THE EMPTY LINE BELOW ###
......
......@@ -173,7 +173,9 @@ ChromaTS : 1
AffineAmvrEncOpt : 1
MmvdDisNum : 6
TemporalFilter : 1
ALFStrength : 1.0
ALFAllowPredefinedFilters : 1
CCALFStrength : 1.0
### DO NOT ADD ANYTHING BELOW THIS LINE ###
### DO NOT DELETE THE EMPTY LINE BELOW ###
......
......@@ -157,7 +157,9 @@ ChromaTS : 1
AffineAmvrEncOpt : 1
MmvdDisNum : 6
TemporalFilter : 1
ALFStrength : 1.0
ALFAllowPredefinedFilters : 1
CCALFStrength : 1.0
### DO NOT ADD ANYTHING BELOW THIS LINE ###
### DO NOT DELETE THE EMPTY LINE BELOW ###
......
\documentclass[a4paper,11pt]{jvetdoc}
\documentclass[a4paper,11pt]{jvetdoc}
\usepackage{geometry}[2010/02/12]
......@@ -2888,6 +2888,18 @@ 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. Valid values are in the range 0.0 to 1.0. NOTE: Refinement of quantized filter coefficents is not used when ALFStrength is different from 1.0. To ensure reduced filter strength the parameter ALFAllowPredefinedFilters should also be set to false.
\\
\Option{ALFAllowPredefinedFilters} &
%\ShortOption{\None} &
\Default{true} &
Enables use of pre-defined filters for ALF.
\\
\Option{CCALF} &
%\ShortOption{\None} &
\Default{true} &
......@@ -2900,6 +2912,12 @@ Enables cross-component ALF.
QP threshold above which the encoder reduces cross-component ALF usage.
\\
\Option{CCALFStrength} &
%\ShortOption{\None} &
\Default{1.0} &
Enables control of CCALF filter strength. The parameter scales the magnitudes of the CCALF filter coefficients. Valid values are in the range 0.0 to 1.0. NOTE: Refinement of quantized filter coefficents is not used when CCALFStrength is different from 1.0.
\\
\Option{SMVD} &
%\ShortOption{\None} &
\Default{false} &
......
......@@ -1048,6 +1048,11 @@ void EncApp::xInitLibCfg()
m_cEncLib.setForceSingleSplitThread ( m_forceSplitSequential );
#endif
m_cEncLib.setUseALF ( m_alf );
#if JVET_T0064
m_cEncLib.setALFStrength (m_alfStrength);
m_cEncLib.setCCALFStrength (m_ccalfStrength);
m_cEncLib.setALFAllowPredefinedFilters (m_alfAllowPredefinedFilters);
#endif
m_cEncLib.setUseCCALF ( m_ccalf );
m_cEncLib.setCCALFQpThreshold ( m_ccalfQpThreshold );
m_cEncLib.setLmcs ( m_lmcsEnabled );
......
......@@ -1403,6 +1403,11 @@ 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. Valid range is 0.0 <= ALFStrength <= 1.0")
("ALFAllowPredefinedFilters", m_alfAllowPredefinedFilters, true, "Allow use of predefined filters for ALF")
("CCALFStrength", m_ccalfStrength, 1.0, "Cross-component Adaptive Loop Filter strength. The parameter scales the magnitudes of the CCALF filter coefficients. Valid range is 0.0 <= CCALFStrength <= 1.0")
#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" )
......@@ -2762,6 +2767,18 @@ bool EncAppCfg::xCheckParameter()
msg( WARNING, "****************************************************************************\n");
m_dualTree = false;
}
#if JVET_T0064
if (m_alf)
{
xConfirmPara(m_alfStrength < 0.0, "ALFStrength is less than 0. Valid range is 0.0 <= ALFStrength <= 1.0" );
xConfirmPara(m_alfStrength > 1.0, "ALFStrength is greater than 1. Valid range is 0.0 <= ALFStrength <= 1.0" );
}
if (m_ccalf)
{
xConfirmPara(m_ccalfStrength < 0.0, "CCALFStrength is less than 0. Valid range is 0.0 <= CCALFStrength <= 1.0");
xConfirmPara(m_ccalfStrength > 1.0, "CCALFStrength is greater than 1. Valid range is 0.0 <= CCALFStrength <= 1.0");
}
#endif
if (m_ccalf && (m_chromaFormatIDC == CHROMA_400))
{
msg( WARNING, "****************************************************************************\n");
......
......@@ -694,6 +694,11 @@ protected:
bool m_forceDecodeBitstream1;
bool m_alf; ///< Adaptive Loop Filter
#if JVET_T0064
double m_alfStrength;
bool m_alfAllowPredefinedFilters;
double m_ccalfStrength;
#endif
bool m_ccalf;
int m_ccalfQpThreshold;
......
......@@ -69,6 +69,7 @@
#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
}
}
......@@ -1892,7 +1901,11 @@ void EncAdaptiveLoopFilter::roundFiltCoeffCCALF(int16_t *filterCoeffQuant, doubl
int best_index = 0;
for(int k = 0; k < CCALF_CANDS_COEFF_NR; k++)
{
#if JVET_T0064
double err = ((filterCoeff[i] * m_encCfg->getCCALFStrength()) * sign * factor - CCALF_SMALL_TAB[k]);
#else
double err = (filterCoeff[i] * sign * factor - CCALF_SMALL_TAB[k]);
#endif
err = err*err;
if(err < best_err)
{
......@@ -2721,7 +2734,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->getALFAllowPredefinedFilters())
{
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);
......@@ -3337,6 +3359,12 @@ void EncAdaptiveLoopFilter::deriveCcAlfFilterCoeff( ComponentID compID, const Pe
// Refine quanitzation
int modified = 1;
#if JVET_T0064
if (m_encCfg->getCCALFStrength() != 1.0)
{
modified = 0;
}
#endif
double errRef = m_alfCovarianceFrameCcAlf[compID - 1][0][filterIdx].calcErrorForCcAlfCoeffs(filterCoeffInt, size, (m_scaleBits+1));
while (modified)
{
......
......@@ -738,6 +738,11 @@ protected:
#endif
bool m_alf; ///< Adaptive Loop Filter
#if JVET_T0064
double m_alfStrength;
bool m_alfAllowPredefinedFilters;
double m_ccalfStrength;
#endif
bool m_ccalf;
int m_ccalfQpThreshold;
#if JVET_O0756_CALCULATE_HDRMETRICS
......@@ -1923,6 +1928,14 @@ 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; }
void setALFAllowPredefinedFilters(bool b) { m_alfAllowPredefinedFilters = b; }
bool getALFAllowPredefinedFilters() const { return m_alfAllowPredefinedFilters; }
void setCCALFStrength(double s) { m_ccalfStrength = s; }
double getCCALFStrength() const { return m_ccalfStrength; }
#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