Commit f185ffee authored by Philippe Hanhart's avatar Philippe Hanhart

JVET-M0142:

Adding support for chroma sample location type 2 in CCLM
parent aa9eaa7c
......@@ -224,6 +224,9 @@ void EncApp::xInitLibCfg()
m_cEncLib.setDisableMotionCompression ( m_DisableMotionCompression );
m_cEncLib.setMTTMode ( m_MTT );
m_cEncLib.setUseLMChroma ( m_LMChroma );
#if JVET_M0142_CCLM_COLLOCATED_CHROMA
m_cEncLib.setCclmCollocatedChromaFlag ( m_cclmCollocatedChromaFlag );
#endif
#if ENABLE_WPP_PARALLELISM
m_cEncLib.setUseAltDQPCoding ( m_AltDQPCoding );
#endif
......
......@@ -828,6 +828,11 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
("LMChroma", m_LMChroma, 1, " LMChroma prediction "
"\t0: Disable LMChroma\n"
"\t1: Enable LMChroma\n")
#if JVET_M0142_CCLM_COLLOCATED_CHROMA
("CclmCollocatedChroma", m_cclmCollocatedChromaFlag, false, "Specifies the location of the top-left downsampled luma sample in cross-component linear model intra prediction relative to the top-left luma sample\n"
"\t0: horizontally co-sited, vertically shifted by 0.5 units of luma samples\n"
"\t1: collocated\n")
#endif
#if JVET_M0464_UNI_MTS
("MTS", m_MTS, 0, "Multiple Transform Set (MTS)\n"
"\t0: Disable MTS\n"
......@@ -3124,6 +3129,12 @@ void EncAppCfg::xPrintParameter()
msg( VERBOSE, "AltDQPCoding:%d ", m_AltDQPCoding );
#endif
msg( VERBOSE, "LMChroma:%d ", m_LMChroma );
#if JVET_M0142_CCLM_COLLOCATED_CHROMA
if( m_LMChroma && m_chromaFormatIDC == CHROMA_420 )
{
msg( VERBOSE, "CclmCollocatedChroma:%d ", m_cclmCollocatedChromaFlag );
}
#endif
#if JVET_M0464_UNI_MTS
msg( VERBOSE, "MTS: %1d(intra) %1d(inter) ", m_MTS & 1, ( m_MTS >> 1 ) & 1 );
#else
......
......@@ -214,6 +214,9 @@ protected:
bool m_AltDQPCoding;
#endif
int m_LMChroma;
#if JVET_M0142_CCLM_COLLOCATED_CHROMA
bool m_cclmCollocatedChromaFlag;
#endif
#if JVET_M0464_UNI_MTS
int m_MTS; ///< XZ: Multiple Transform Set
int m_MTSIntraMaxCand; ///< XZ: Number of additional candidates to test
......
......@@ -1563,6 +1563,24 @@ void IntraPrediction::xGetLumaRecPixels(const PredictionUnit &pu, CompArea chrom
pDst[i] = ( piSrc[2 * i] * 2 + piSrc[2 * i - 1] + piSrc[2 * i + 1] + 2 ) >> 2;
}
}
#if JVET_M0142_CCLM_COLLOCATED_CHROMA
else if( pu.cs->sps->getSpsNext().getCclmCollocatedChromaFlag() )
{
piSrc = pRecSrc0 - iRecStride2;
if( i == 0 && !bLeftAvaillable )
{
pDst[i] = ( piSrc[2 * i] * 2 + piSrc[2 * i - iRecStride] + piSrc[2 * i + iRecStride] + 2 ) >> 2;
}
else
{
pDst[i] = ( piSrc[2 * i - iRecStride]
+ piSrc[2 * i ] * 4 + piSrc[2 * i - 1] + piSrc[2 * i + 1]
+ piSrc[2 * i + iRecStride]
+ 4 ) >> 3;
}
}
#endif
else
{
piSrc = pRecSrc0 - iRecStride2;
......@@ -1592,9 +1610,30 @@ void IntraPrediction::xGetLumaRecPixels(const PredictionUnit &pu, CompArea chrom
}
for (int j = 0; j < uiCHeight + addedLeftBelow; j++)
{
pDst[0] = ( ( piSrc[1 ] * 2 + piSrc[0 ] + piSrc[2 ] )
+ ( piSrc[1 + iRecStride] * 2 + piSrc[iRecStride] + piSrc[2 + iRecStride] )
+ 4 ) >> 3;
#if JVET_M0142_CCLM_COLLOCATED_CHROMA
if( pu.cs->sps->getSpsNext().getCclmCollocatedChromaFlag() )
{
if( j == 0 && !bAboveAvaillable )
{
pDst[0] = ( piSrc[1] * 2 + piSrc[0] + piSrc[2] + 2 ) >> 2;
}
else
{
pDst[0] = ( piSrc[1 - iRecStride]
+ piSrc[1 ] * 4 + piSrc[0] + piSrc[2]
+ piSrc[1 + iRecStride]
+ 4 ) >> 3;
}
}
else
{
#endif
pDst[0] = ( ( piSrc[1 ] * 2 + piSrc[0 ] + piSrc[2 ] )
+ ( piSrc[1 + iRecStride] * 2 + piSrc[iRecStride] + piSrc[2 + iRecStride] )
+ 4 ) >> 3;
#if JVET_M0142_CCLM_COLLOCATED_CHROMA
}
#endif
piSrc += iRecStride2;
pDst += iDstStride;
......@@ -1607,16 +1646,48 @@ void IntraPrediction::xGetLumaRecPixels(const PredictionUnit &pu, CompArea chrom
{
for( int i = 0; i < uiCWidth; i++ )
{
if( i == 0 && !bLeftAvaillable )
#if JVET_M0142_CCLM_COLLOCATED_CHROMA
if( pu.cs->sps->getSpsNext().getCclmCollocatedChromaFlag() )
{
pDst0[i] = ( pRecSrc0[2 * i] + pRecSrc0[2 * i + iRecStride] + 1 ) >> 1;
if( i == 0 && !bLeftAvaillable )
{
if( j == 0 && !bAboveAvaillable )
{
pDst0[i] = pRecSrc0[2 * i];
}
else
{
pDst0[i] = ( pRecSrc0[2 * i] * 2 + pRecSrc0[2 * i - iRecStride] + pRecSrc0[2 * i + iRecStride] + 2 ) >> 2;
}
}
else if( j == 0 && !bAboveAvaillable )
{
pDst0[i] = ( pRecSrc0[2 * i] * 2 + pRecSrc0[2 * i - 1] + pRecSrc0[2 * i + 1] + 2 ) >> 2;
}
else
{
pDst0[i] = ( pRecSrc0[2 * i - iRecStride]
+ pRecSrc0[2 * i ] * 4 + pRecSrc0[2 * i - 1] + pRecSrc0[2 * i + 1]
+ pRecSrc0[2 * i + iRecStride]
+ 4 ) >> 3;
}
}
else
{
pDst0[i] = ( pRecSrc0[2 * i ] * 2 + pRecSrc0[2 * i + 1 ] + pRecSrc0[2 * i - 1 ]
+ pRecSrc0[2 * i + iRecStride] * 2 + pRecSrc0[2 * i + 1 + iRecStride] + pRecSrc0[2 * i - 1 + iRecStride]
+ 4 ) >> 3;
#endif
if( i == 0 && !bLeftAvaillable )
{
pDst0[i] = ( pRecSrc0[2 * i] + pRecSrc0[2 * i + iRecStride] + 1 ) >> 1;
}
else
{
pDst0[i] = ( pRecSrc0[2 * i ] * 2 + pRecSrc0[2 * i + 1 ] + pRecSrc0[2 * i - 1 ]
+ pRecSrc0[2 * i + iRecStride] * 2 + pRecSrc0[2 * i + 1 + iRecStride] + pRecSrc0[2 * i - 1 + iRecStride]
+ 4 ) >> 3;
}
#if JVET_M0142_CCLM_COLLOCATED_CHROMA
}
#endif
}
pDst0 += iDstStride;
......
......@@ -1738,6 +1738,9 @@ SPSNext::SPSNext( SPS& sps )
, m_BIO ( false )
, m_DisableMotionCompression ( false )
, m_LMChroma ( false )
#if JVET_M0142_CCLM_COLLOCATED_CHROMA
, m_cclmCollocatedChromaFlag ( false )
#endif
#if JVET_M0464_UNI_MTS
, m_IntraMTS ( false )
, m_InterMTS ( false )
......
......@@ -804,6 +804,9 @@ private:
bool m_BIO;
bool m_DisableMotionCompression; // 13
bool m_LMChroma; // 17
#if JVET_M0142_CCLM_COLLOCATED_CHROMA
bool m_cclmCollocatedChromaFlag;
#endif
#if JVET_M0464_UNI_MTS
bool m_IntraMTS; // 18
bool m_InterMTS; // 19
......@@ -877,6 +880,10 @@ public:
#endif
void setUseLMChroma ( bool b ) { m_LMChroma = b; }
bool getUseLMChroma () const { return m_LMChroma; }
#if JVET_M0142_CCLM_COLLOCATED_CHROMA
void setCclmCollocatedChromaFlag( bool b ) { m_cclmCollocatedChromaFlag = b; }
bool getCclmCollocatedChromaFlag() const { return m_cclmCollocatedChromaFlag; }
#endif
#if JVET_M0464_UNI_MTS
void setUseIntraMTS ( bool b ) { m_IntraMTS = b; }
bool getUseIntraMTS () const { return m_IntraMTS; }
......
......@@ -50,6 +50,8 @@
#include <assert.h>
#include <cassert>
#define JVET_M0142_CCLM_COLLOCATED_CHROMA 1 // Adding support for chroma sample location type 2 in CCLM
#define JVET_M0479_18BITS_MV_CLIP 1
#define JVET_M0464_UNI_MTS 1
......
......@@ -794,6 +794,12 @@ void HLSyntaxReader::parseSPSNext( SPSNext& spsNext, const bool usePCM )
READ_FLAG( symbol, "bio_enable_flag" ); spsNext.setUseBIO ( symbol != 0 );
READ_FLAG( symbol, "disable_motion_compression_flag" ); spsNext.setDisableMotCompress ( symbol != 0 );
READ_FLAG( symbol, "lm_chroma_enabled_flag" ); spsNext.setUseLMChroma ( symbol != 0 );
#if JVET_M0142_CCLM_COLLOCATED_CHROMA
if ( spsNext.getUseLMChroma() && spsNext.getSPS().getChromaFormatIdc() == CHROMA_420 )
{
READ_FLAG( symbol, "sps_cclm_collocated_chroma_flag" ); spsNext.setCclmCollocatedChromaFlag( symbol != 0 );
}
#endif
#if JVET_M0464_UNI_MTS
READ_FLAG( symbol, "mts_intra_enabled_flag" ); spsNext.setUseIntraMTS ( symbol != 0 );
READ_FLAG( symbol, "mts_inter_enabled_flag" ); spsNext.setUseInterMTS ( symbol != 0 );
......
......@@ -202,6 +202,9 @@ protected:
unsigned m_log2DiffMaxMinCodingBlockSize;
int m_LMChroma;
#if JVET_M0142_CCLM_COLLOCATED_CHROMA
bool m_cclmCollocatedChromaFlag;
#endif
#if JVET_M0464_UNI_MTS
int m_IntraMTS;
int m_InterMTS;
......@@ -681,6 +684,10 @@ public:
void setUseLMChroma ( int n ) { m_LMChroma = n; }
int getUseLMChroma() const { return m_LMChroma; }
#if JVET_M0142_CCLM_COLLOCATED_CHROMA
void setCclmCollocatedChromaFlag ( bool b ) { m_cclmCollocatedChromaFlag = b; }
bool getCclmCollocatedChromaFlag () const { return m_cclmCollocatedChromaFlag; }
#endif
void setSubPuMvpMode(int n) { m_SubPuMvpMode = n; }
bool getSubPuMvpMode() const { return m_SubPuMvpMode; }
......
......@@ -860,6 +860,9 @@ void EncLib::xInitSPS(SPS &sps)
sps.getSpsNext().setDisableMotCompress ( m_DisableMotionCompression );
sps.getSpsNext().setMTTMode ( m_MTTMode );
sps.getSpsNext().setUseLMChroma ( m_LMChroma ? true : false );
#if JVET_M0142_CCLM_COLLOCATED_CHROMA
sps.getSpsNext().setCclmCollocatedChromaFlag( m_cclmCollocatedChromaFlag );
#endif
#if ENABLE_WPP_PARALLELISM
sps.getSpsNext().setUseNextDQP ( m_AltDQPCoding );
#endif
......
......@@ -534,6 +534,12 @@ void HLSWriter::codeSPSNext( const SPSNext& spsNext, const bool usePCM )
WRITE_FLAG( spsNext.getUseBIO() ? 1 : 0, "bio_enable_flag" );
WRITE_FLAG( spsNext.getDisableMotCompress() ? 1 : 0, "disable_motion_compression_flag" );
WRITE_FLAG( spsNext.getUseLMChroma() ? 1 : 0, "lm_chroma_enabled_flag" );
#if JVET_M0142_CCLM_COLLOCATED_CHROMA
if ( spsNext.getUseLMChroma() && spsNext.getSPS().getChromaFormatIdc() == CHROMA_420 )
{
WRITE_FLAG( spsNext.getCclmCollocatedChromaFlag() ? 1 : 0, "sps_cclm_collocated_chroma_flag" );
}
#endif
#if JVET_M0464_UNI_MTS
WRITE_FLAG( spsNext.getUseIntraMTS() ? 1 : 0, "mts_intra_enabled_flag" );
WRITE_FLAG( spsNext.getUseInterMTS() ? 1 : 0, "mts_inter_enabled_flag" );
......
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