diff --git a/doc/software-manual.tex b/doc/software-manual.tex index aa92e1c289b8e093daad9ae0fe473419a387ea41..a9e299004cc29bf13a7bb64b6f52215fe083e2cd 100644 --- a/doc/software-manual.tex +++ b/doc/software-manual.tex @@ -3524,23 +3524,30 @@ Enables or disables the use of adaptive color transform (ACT). \Option{HorCollocatedChroma} & %\ShortOption{\None} & -\Default{true} & -Specifies location of a chroma sample relatively to the luma sample in horizontal direction in the reference picture resampling. +\Default{-1} & +Specifies location of top-left chroma sample relative to top-left luma sample in horizontal direction for reference picture resampling. +For chroma formats other than 4:2:0, the value defaults to 1. +When ChromaSampleLocType is equal to 6 (unspecified) and HorCollocatedChroma is equal to -1, the value defaults to 1. \par \begin{tabular}{cp{0.45\textwidth}} - 0 & horizontally shifted by 0.5 units of luma samples.\\ - 1 & collocated (default). \\ + -1 & value based on ChromaSampleLocType (default)\\ + 0 & horizontally shifted by 0.5 units of luma samples\\ + 1 & collocated \\ \end{tabular} \\ \Option{VerCollocatedChroma} & %\ShortOption{\None} & -\Default{false} & -Specifies location of a chroma sample relatively to the luma sample in vertical direction in the cross-component linear model intra prediction and the reference picture resampling. +\Default{-1} & +Specifies location of top-left chroma sample relative to top-left luma sample in vertical direction for cross-component linear model (CCLM) +intra prediction and for reference picture resampling. +For chroma formats other than 4:2:0, the value defaults to 1. +When ChromaSampleLocType is equal to 6 (unspecified) and VerCollocatedChroma is equal to -1, the value defaults to 0. \par \begin{tabular}{cp{0.45\textwidth}} - 0 & vertically shifted by 0.5 units of luma samples (default).\\ - 1 & collocated. \\ + -1 & value based on ChromaSampleLocType (default)\\ + 0 & vertically shifted by 0.5 units of luma samples\\ + 1 & collocated\\ \end{tabular} \\ diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp index a8ab6c746c0df2756fcfa08c4be36f913cbadac1..401c6a745c4c2d1970c0548bb91094fd7d08a914 100644 --- a/source/App/EncoderApp/EncApp.cpp +++ b/source/App/EncoderApp/EncApp.cpp @@ -733,8 +733,8 @@ void EncApp::xInitLibCfg( int layerIdx ) m_cEncLib.setPROF ( m_PROF ); m_cEncLib.setBIO (m_BIO); m_cEncLib.setUseLMChroma ( m_LMChroma ); - m_cEncLib.setHorCollocatedChromaFlag ( m_horCollocatedChromaFlag ); - m_cEncLib.setVerCollocatedChromaFlag ( m_verCollocatedChromaFlag ); + m_cEncLib.setHorCollocatedChromaFlag(m_horCollocatedChromaFlag != 0); + m_cEncLib.setVerCollocatedChromaFlag(m_verCollocatedChromaFlag != 0); m_cEncLib.setExplicitMtsIntraEnabled((m_mtsMode & 1) != 0); m_cEncLib.setExplicitMtsInterEnabled((m_mtsMode & 2) != 0); m_cEncLib.setMTSIntraMaxCand ( m_MTSIntraMaxCand ); @@ -1731,7 +1731,9 @@ bool EncApp::encodePrep( bool& eos ) bool downsampling = (m_sourceWidthBeforeScale > m_sourceWidth) || (m_sourceHeightBeforeScale > m_sourceHeight); bool useLumaFilter = downsampling; - Picture::rescalePicture(scalingRatio, *m_orgPicBeforeScale, Window(), *m_orgPic, conformanceWindow1, m_inputChromaFormatIDC , m_internalBitDepth,useLumaFilter,downsampling,m_horCollocatedChromaFlag,m_verCollocatedChromaFlag ); + Picture::rescalePicture(scalingRatio, *m_orgPicBeforeScale, Window(), *m_orgPic, conformanceWindow1, + m_inputChromaFormatIDC, m_internalBitDepth, useLumaFilter, downsampling, + m_horCollocatedChromaFlag != 0, m_verCollocatedChromaFlag != 0); m_trueOrgPic->copyFrom(*m_orgPic); } else diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp index 12d84e3af49e54025bb2df0d0eb4c340664ec378..d5f5571f2f03acceec606e8046af674365d01ebf 100644 --- a/source/App/EncoderApp/EncAppCfg.cpp +++ b/source/App/EncoderApp/EncAppCfg.cpp @@ -1014,10 +1014,12 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("LMChroma", m_LMChroma, 1, " LMChroma prediction " "\t0: Disable LMChroma\n" "\t1: Enable LMChroma\n") - ("HorCollocatedChroma", m_horCollocatedChromaFlag, true, "Specifies location of a chroma sample relatively to the luma sample in horizontal direction in the reference picture resampling\n" + ("HorCollocatedChroma", m_horCollocatedChromaFlag, -1, "Specifies location of a chroma sample relatively to the luma sample in horizontal direction in the reference picture resampling\n" + "\t-1: set according to chroma location type (default)\n" "\t0: horizontally shifted by 0.5 units of luma samples\n" - "\t1: collocated (default)\n") - ("VerCollocatedChroma", m_verCollocatedChromaFlag, false, "Specifies location of a chroma sample relatively to the luma sample in vertical direction in the cross-component linear model intra prediction and the reference picture resampling\n" + "\t1: collocated\n") + ("VerCollocatedChroma", m_verCollocatedChromaFlag, -1, "Specifies location of a chroma sample relatively to the luma sample in vertical direction in the cross-component linear model intra prediction and the reference picture resampling\n" + "\t-1: set according to chroma location type (default)\n" "\t0: horizontally co-sited, vertically shifted by 0.5 units of luma samples\n" "\t1: collocated\n") ("MTS", m_mtsMode, 0, "Multiple Transform Set (MTS)\n" @@ -2897,17 +2899,58 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) if (m_chromaFormatIdc != ChromaFormat::_420) { - if (!m_horCollocatedChromaFlag) + if (m_horCollocatedChromaFlag != 1) { - msg(WARNING, "\nWARNING: HorCollocatedChroma is forced to 1 for chroma formats other than 4:2:0\n"); - m_horCollocatedChromaFlag = true; + if (m_horCollocatedChromaFlag == 0) + { + msg(WARNING, "WARNING: HorCollocatedChroma forced to 1 (chroma format is not 4:2:0)\n"); + } + m_horCollocatedChromaFlag = 1; } - if (!m_verCollocatedChromaFlag) + if (m_verCollocatedChromaFlag != 1) { - msg(WARNING, "\nWARNING: VerCollocatedChroma is forced to 1 for chroma formats other than 4:2:0\n"); - m_verCollocatedChromaFlag = true; + if (m_verCollocatedChromaFlag == 0) + { + msg(WARNING, "WARNING: VerCollocatedChroma is forced to 1 (chroma format is not 4:2:0)\n"); + } + m_verCollocatedChromaFlag = 1; } } + else + { + if (m_horCollocatedChromaFlag == -1) + { + if (m_chromaSampleLocType != Chroma420LocType::UNSPECIFIED) + { + m_horCollocatedChromaFlag = m_chromaSampleLocType == Chroma420LocType::LEFT + || m_chromaSampleLocType == Chroma420LocType::TOP_LEFT + || m_chromaSampleLocType == Chroma420LocType::BOTTOM_LEFT + ? 1 + : 0; + } + else + { + m_horCollocatedChromaFlag = 1; + } + } + + if (m_verCollocatedChromaFlag == -1) + { + if (m_chromaSampleLocType != Chroma420LocType::UNSPECIFIED) + { + m_verCollocatedChromaFlag = + m_chromaSampleLocType == Chroma420LocType::TOP_LEFT || m_chromaSampleLocType == Chroma420LocType::TOP ? 1 : 0; + } + else + { + m_verCollocatedChromaFlag = 0; + } + } + } + + CHECK(m_verCollocatedChromaFlag != 0 && m_verCollocatedChromaFlag != 1, "m_verCollocatedChromaFlag should be 0 or 1"); + CHECK(m_horCollocatedChromaFlag != 0 && m_horCollocatedChromaFlag != 1, "m_horCollocatedChromaFlag should be 0 or 1"); + #if JVET_O0756_CONFIG_HDRMETRICS && !JVET_O0756_CALCULATE_HDRMETRICS if ( m_calculateHdrMetrics == true) { diff --git a/source/App/EncoderApp/EncAppCfg.h b/source/App/EncoderApp/EncAppCfg.h index 712830e729b9865ebed0d419270d1ee81ca80d82..af2423f69c7d5d0a75ff47cc8246de5a0436bd93 100644 --- a/source/App/EncoderApp/EncAppCfg.h +++ b/source/App/EncoderApp/EncAppCfg.h @@ -354,8 +354,8 @@ protected: bool m_PROF; bool m_BIO; int m_LMChroma; - bool m_horCollocatedChromaFlag; - bool m_verCollocatedChromaFlag; + int m_horCollocatedChromaFlag; + int m_verCollocatedChromaFlag; int m_mtsMode; ///< XZ: Multiple Transform Set int m_MTSIntraMaxCand; ///< XZ: Number of additional candidates to test