From da9126df5d5b8bb444625c40782072fe71f32b14 Mon Sep 17 00:00:00 2001 From: Kenneth Andersson <kenneth.r.andersson@ericsson.com> Date: Wed, 18 Nov 2020 16:36:01 +0100 Subject: [PATCH] Also added parameters ALFAllowPredefinedFilters and CCALFStrength and note on that that refinement of quantized filter coefficients not is used. --- cfg/encoder_intra_vtm.cfg | 5 +++-- cfg/encoder_lowdelay_P_vtm.cfg | 4 +++- cfg/encoder_lowdelay_vtm.cfg | 4 +++- cfg/encoder_randomaccess_vtm.cfg | 5 +++-- cfg/encoder_randomaccess_vtm_gop16.cfg | 5 +++-- doc/software-manual.tex | 16 ++++++++++++++-- source/App/EncoderApp/EncApp.cpp | 2 ++ source/App/EncoderApp/EncAppCfg.cpp | 9 ++++++++- source/App/EncoderApp/EncAppCfg.h | 2 ++ source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp | 12 +++++++++++- source/Lib/EncoderLib/EncCfg.h | 8 +++++++- 11 files changed, 59 insertions(+), 13 deletions(-) diff --git a/cfg/encoder_intra_vtm.cfg b/cfg/encoder_intra_vtm.cfg index bcbc82566..4509605d9 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 228b11448..35b2291f4 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 7128d34d7..5818fb1f7 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 7335eb88b..9ca9d6f62 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 ad36d6b97..e44197cf9 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 3be3237eb..6031fb5c0 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 6cd69d352..67be5dd88 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 7ffe12785..b38001ebc 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 8b193490f..47b2ce682 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 5aa96f3d0..c4f260b2e 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 9ec010637..fa16f2895 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; } -- GitLab