diff --git a/cfg/encoder_intra_vtm.cfg b/cfg/encoder_intra_vtm.cfg index bcbc825667b99c97fa8567d5b24595425af38bcc..4509605d9beee1255c1699fac1f2cb88cc040b26 100644 --- a/cfg/encoder_intra_vtm.cfg +++ b/cfg/encoder_intra_vtm.cfg @@ -88,7 +88,6 @@ 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,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 ### diff --git a/cfg/encoder_lowdelay_P_vtm.cfg b/cfg/encoder_lowdelay_P_vtm.cfg index 228b11448597b7f545d326f07e6fe2b9c77fa505..35b2291f4762f1177be73214459901519073c59d 100644 --- a/cfg/encoder_lowdelay_P_vtm.cfg +++ b/cfg/encoder_lowdelay_P_vtm.cfg @@ -111,7 +111,6 @@ LMChroma : 1 # use CCLM only DepQuant : 1 IMV : 1 ALF : 1 -ALFStrength : 1.0 CIIP : 1 IBC : 0 # turned off in CTC AllowDisFracMMVD : 1 @@ -137,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 ### diff --git a/cfg/encoder_lowdelay_vtm.cfg b/cfg/encoder_lowdelay_vtm.cfg index 7128d34d7704f00ce0ec7c63a9ac763153b5ff19..5818fb1f7ad45e3d7a5c6e2cac34fa77ca7a4406 100644 --- a/cfg/encoder_lowdelay_vtm.cfg +++ b/cfg/encoder_lowdelay_vtm.cfg @@ -112,7 +112,6 @@ LMChroma : 1 # use CCLM only DepQuant : 1 IMV : 1 ALF : 1 -ALFStrength : 1.0 BCW : 1 BcwFast : 1 CIIP : 1 @@ -141,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 ### diff --git a/cfg/encoder_randomaccess_vtm.cfg b/cfg/encoder_randomaccess_vtm.cfg index 7335eb88b4b476c072c585f1de531e933a850e34..9ca9d6f62d2c0744312a6c126f95badcd4e381e5 100644 --- a/cfg/encoder_randomaccess_vtm.cfg +++ b/cfg/encoder_randomaccess_vtm.cfg @@ -140,7 +140,6 @@ LMChroma : 1 # use CCLM only DepQuant : 1 IMV : 1 ALF : 1 -ALFStrength : 1.0 BCW : 1 BcwFast : 1 BIO : 1 @@ -174,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 ### diff --git a/cfg/encoder_randomaccess_vtm_gop16.cfg b/cfg/encoder_randomaccess_vtm_gop16.cfg index ad36d6b97d06e2e5c29e47fded7445b3a0051275..e44197cf949c9058899effc6d5516501bc2c0921 100644 --- a/cfg/encoder_randomaccess_vtm_gop16.cfg +++ b/cfg/encoder_randomaccess_vtm_gop16.cfg @@ -124,7 +124,6 @@ LMChroma : 1 # use CCLM only DepQuant : 1 IMV : 1 ALF : 1 -ALFStrength : 1.0 BCW : 1 BcwFast : 1 BIO : 1 @@ -158,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 ### diff --git a/doc/software-manual.tex b/doc/software-manual.tex index 3be3237eb2690622bd7aa72480fd88c6d2da4e4b..6031fb5c0885ac604bdae0559f9270933a11dc48 100644 --- a/doc/software-manual.tex +++ b/doc/software-manual.tex @@ -1,4 +1,4 @@ -\documentclass[a4paper,11pt]{jvetdoc} +\documentclass[a4paper,11pt]{jvetdoc} \usepackage{geometry}[2010/02/12] @@ -2891,7 +2891,13 @@ 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. +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} & @@ -2906,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} & diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp index 6cd69d352e2598097417cc0d5cb0021970e2170b..67be5dd888deebcf0e3f1d41b2e28ccab3f317a7 100644 --- a/source/App/EncoderApp/EncApp.cpp +++ b/source/App/EncoderApp/EncApp.cpp @@ -1050,6 +1050,8 @@ void EncApp::xInitLibCfg() 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 ); diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp index 7ffe12785e90e135ee46882a403744e3bcc9a0c7..b38001ebc7d825596bfc05e3253bb7dcd021f7d9 100644 --- a/source/App/EncoderApp/EncAppCfg.cpp +++ b/source/App/EncoderApp/EncAppCfg.cpp @@ -1404,7 +1404,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("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") + ("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") @@ -2771,6 +2773,11 @@ bool EncAppCfg::xCheckParameter() 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)) { diff --git a/source/App/EncoderApp/EncAppCfg.h b/source/App/EncoderApp/EncAppCfg.h index 8b193490f511439f45953f384fd8c7c9948bb9a6..47b2ce6827ae091755cd3bd7a3a841af919de156 100644 --- a/source/App/EncoderApp/EncAppCfg.h +++ b/source/App/EncoderApp/EncAppCfg.h @@ -696,6 +696,8 @@ protected: 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; diff --git a/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp b/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp index 5aa96f3d0d14d543ab7ddd39bac1ea10900b1f19..c4f260b2ee8a45a4b4e1dfaf18bc60347a256ebd 100644 --- a/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp +++ b/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp @@ -1901,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) { @@ -2732,7 +2736,7 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfPar int iBestFilterSetIdx = 0; #if JVET_T0064 int firstFilterSetIdx = 0; - if (m_encCfg->getALFStrength() != 1.0) + if (!m_encCfg->getALFAllowPredefinedFilters()) { firstFilterSetIdx = NUM_FIXED_FILTER_SETS; } @@ -3355,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) { diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h index 9ec0106370adc1e96e252e1bda386181a9e280c8..fa16f2895268bf28700edff711e19d0ead12c15d 100644 --- a/source/Lib/EncoderLib/EncCfg.h +++ b/source/Lib/EncoderLib/EncCfg.h @@ -740,6 +740,8 @@ protected: 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; @@ -1927,8 +1929,12 @@ public: void setUseALF( bool b ) { m_alf = b; } bool getUseALF() const { return m_alf; } #if JVET_T0064 - void setALFStrength( double s) { m_alfStrength = s; } + 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; }