Commit 5529412a authored by Yung-Hsuan Chao (Jessie)'s avatar Yung-Hsuan Chao (Jessie)
Browse files

initial commit of JVET_O0119_BASE_PALETTE_444: palette in HEVC and palette...

initial commit of JVET_O0119_BASE_PALETTE_444: palette in HEVC and palette mode coding in JVET-N0258
parent b8a28645
...@@ -290,6 +290,9 @@ void EncApp::xInitLibCfg() ...@@ -290,6 +290,9 @@ void EncApp::xInitLibCfg()
m_cEncLib.setMMVD ( m_MMVD ); m_cEncLib.setMMVD ( m_MMVD );
m_cEncLib.setMmvdDisNum (m_MmvdDisNum); m_cEncLib.setMmvdDisNum (m_MmvdDisNum);
m_cEncLib.setRDPCM ( m_RdpcmMode ); m_cEncLib.setRDPCM ( m_RdpcmMode );
#if JVET_O0119_BASE_PALETTE_444
m_cEncLib.setPLTMode ( m_PLTMode);
#endif
m_cEncLib.setIBCMode ( m_IBCMode ); m_cEncLib.setIBCMode ( m_IBCMode );
m_cEncLib.setIBCLocalSearchRangeX ( m_IBCLocalSearchRangeX ); m_cEncLib.setIBCLocalSearchRangeX ( m_IBCLocalSearchRangeX );
m_cEncLib.setIBCLocalSearchRangeY ( m_IBCLocalSearchRangeY ); m_cEncLib.setIBCLocalSearchRangeY ( m_IBCLocalSearchRangeY );
......
...@@ -901,6 +901,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ...@@ -901,6 +901,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
("DMVR", m_DMVR, false, "Decoder-side Motion Vector Refinement") ("DMVR", m_DMVR, false, "Decoder-side Motion Vector Refinement")
("MmvdDisNum", m_MmvdDisNum, 8, "Number of MMVD Distance Entries") ("MmvdDisNum", m_MmvdDisNum, 8, "Number of MMVD Distance Entries")
( "RDPCM", m_RdpcmMode, false, "RDPCM") ( "RDPCM", m_RdpcmMode, false, "RDPCM")
#if JVET_O0119_BASE_PALETTE_444
("PLT", m_PLTMode, 0u, "PLTMode (0x1:enabled, 0x0:disabled) [default: disabled]")
#endif
( "IBC", m_IBCMode, 0u, "IBCMode (0x1:enabled, 0x0:disabled) [default: disabled]") ( "IBC", m_IBCMode, 0u, "IBCMode (0x1:enabled, 0x0:disabled) [default: disabled]")
( "IBCLocalSearchRangeX", m_IBCLocalSearchRangeX, 128u, "Search range of IBC local search in x direction") ( "IBCLocalSearchRangeX", m_IBCLocalSearchRangeX, 128u, "Search range of IBC local search in x direction")
( "IBCLocalSearchRangeY", m_IBCLocalSearchRangeY, 128u, "Search range of IBC local search in y direction") ( "IBCLocalSearchRangeY", m_IBCLocalSearchRangeY, 128u, "Search range of IBC local search in y direction")
...@@ -2181,6 +2184,9 @@ bool EncAppCfg::xCheckParameter() ...@@ -2181,6 +2184,9 @@ bool EncAppCfg::xCheckParameter()
#endif #endif
xConfirmPara( m_LMChroma, "LMChroma only allowed with NEXT profile" ); xConfirmPara( m_LMChroma, "LMChroma only allowed with NEXT profile" );
xConfirmPara( m_ImvMode, "IMV is only allowed with NEXT profile" ); xConfirmPara( m_ImvMode, "IMV is only allowed with NEXT profile" );
#if JVET_O0119_BASE_PALETTE_444
xConfirmPara( m_PLTMode, "PLT Mode only allowed with NEXT profile");
#endif
xConfirmPara(m_IBCMode, "IBC Mode only allowed with NEXT profile"); xConfirmPara(m_IBCMode, "IBC Mode only allowed with NEXT profile");
xConfirmPara( m_HashME, "Hash motion estimation only allowed with NEXT profile" ); xConfirmPara( m_HashME, "Hash motion estimation only allowed with NEXT profile" );
xConfirmPara( m_useFastLCTU, "Fast large CTU can only be applied when encoding with NEXT profile" ); xConfirmPara( m_useFastLCTU, "Fast large CTU can only be applied when encoding with NEXT profile" );
...@@ -3367,6 +3373,10 @@ void EncAppCfg::xPrintParameter() ...@@ -3367,6 +3373,10 @@ void EncAppCfg::xPrintParameter()
msg(VERBOSE, "MmvdDisNum:%d ", m_MmvdDisNum); msg(VERBOSE, "MmvdDisNum:%d ", m_MmvdDisNum);
msg(VERBOSE, "RDPCM:%d ", m_RdpcmMode ); msg(VERBOSE, "RDPCM:%d ", m_RdpcmMode );
} }
#if JVET_O0119_BASE_PALETTE_444
m_PLTMode = ( m_chromaFormatIDC == CHROMA_444) ? m_PLTMode : 0u;
msg(VERBOSE, "PLT:%d ", m_PLTMode);
#endif
msg(VERBOSE, "IBC:%d ", m_IBCMode); msg(VERBOSE, "IBC:%d ", m_IBCMode);
msg( VERBOSE, "HashME:%d ", m_HashME ); msg( VERBOSE, "HashME:%d ", m_HashME );
msg( VERBOSE, "WrapAround:%d ", m_wrapAround); msg( VERBOSE, "WrapAround:%d ", m_wrapAround);
......
...@@ -283,6 +283,9 @@ protected: ...@@ -283,6 +283,9 @@ protected:
bool m_MMVD; bool m_MMVD;
int m_MmvdDisNum; int m_MmvdDisNum;
bool m_RdpcmMode; bool m_RdpcmMode;
#if JVET_O0119_BASE_PALETTE_444
unsigned m_PLTMode;
#endif
unsigned m_IBCMode; unsigned m_IBCMode;
unsigned m_IBCLocalSearchRangeX; unsigned m_IBCLocalSearchRangeX;
unsigned m_IBCLocalSearchRangeY; unsigned m_IBCLocalSearchRangeY;
......
...@@ -164,6 +164,13 @@ typedef AreaBuf<const TCoeff> CCoeffBuf; ...@@ -164,6 +164,13 @@ typedef AreaBuf<const TCoeff> CCoeffBuf;
typedef AreaBuf< MotionInfo> MotionBuf; typedef AreaBuf< MotionInfo> MotionBuf;
typedef AreaBuf<const MotionInfo> CMotionBuf; typedef AreaBuf<const MotionInfo> CMotionBuf;
#if JVET_O0119_BASE_PALETTE_444
typedef AreaBuf< TCoeff> PLTescapeBuf;
typedef AreaBuf<const TCoeff> CPLTescapeBuf;
typedef AreaBuf< bool> PLTtypeBuf;
typedef AreaBuf<const bool> CPLTtypeBuf;
#endif
#define SIZE_AWARE_PER_EL_OP( OP, INC ) \ #define SIZE_AWARE_PER_EL_OP( OP, INC ) \
if( ( width & 7 ) == 0 ) \ if( ( width & 7 ) == 0 ) \
......
...@@ -72,6 +72,10 @@ CodingStructure::CodingStructure(CUCache& cuCache, PUCache& puCache, TUCache& tu ...@@ -72,6 +72,10 @@ CodingStructure::CodingStructure(CUCache& cuCache, PUCache& puCache, TUCache& tu
{ {
m_coeffs[ i ] = nullptr; m_coeffs[ i ] = nullptr;
m_pcmbuf[ i ] = nullptr; m_pcmbuf[ i ] = nullptr;
#if JVET_O0119_BASE_PALETTE_444
m_runType[i] = nullptr;
m_runLength[i] = nullptr;
#endif
m_offsets[ i ] = 0; m_offsets[ i ] = 0;
} }
...@@ -501,6 +505,10 @@ TransformUnit& CodingStructure::addTU( const UnitArea &unit, const ChannelType c ...@@ -501,6 +505,10 @@ TransformUnit& CodingStructure::addTU( const UnitArea &unit, const ChannelType c
TCoeff *coeffs[5] = { nullptr, nullptr, nullptr, nullptr, nullptr }; TCoeff *coeffs[5] = { nullptr, nullptr, nullptr, nullptr, nullptr };
Pel *pcmbuf[5] = { nullptr, nullptr, nullptr, nullptr, nullptr }; Pel *pcmbuf[5] = { nullptr, nullptr, nullptr, nullptr, nullptr };
#if JVET_O0119_BASE_PALETTE_444
bool *runType[5] = { nullptr, nullptr, nullptr, nullptr, nullptr };
Pel *runLength[5] = { nullptr, nullptr, nullptr, nullptr, nullptr };
#endif
uint32_t numCh = ::getNumberValidComponents( area.chromaFormat ); uint32_t numCh = ::getNumberValidComponents( area.chromaFormat );
...@@ -537,12 +545,20 @@ TransformUnit& CodingStructure::addTU( const UnitArea &unit, const ChannelType c ...@@ -537,12 +545,20 @@ TransformUnit& CodingStructure::addTU( const UnitArea &unit, const ChannelType c
coeffs[i] = m_coeffs[i] + m_offsets[i]; coeffs[i] = m_coeffs[i] + m_offsets[i];
pcmbuf[i] = m_pcmbuf[i] + m_offsets[i]; pcmbuf[i] = m_pcmbuf[i] + m_offsets[i];
#if JVET_O0119_BASE_PALETTE_444
runType[i] = m_runType[i] + m_offsets[i];
runLength[i] = m_runLength[i] + m_offsets[i];
#endif
unsigned areaSize = tu->blocks[i].area(); unsigned areaSize = tu->blocks[i].area();
m_offsets[i] += areaSize; m_offsets[i] += areaSize;
} }
#if JVET_O0119_BASE_PALETTE_444
tu->init( coeffs, pcmbuf, runLength, runType);
#else
tu->init( coeffs, pcmbuf ); tu->init( coeffs, pcmbuf );
#endif
return *tu; return *tu;
} }
...@@ -705,6 +721,64 @@ void CodingStructure::addMiToLut(static_vector<MotionInfo, MAX_NUM_HMVP_CANDS> & ...@@ -705,6 +721,64 @@ void CodingStructure::addMiToLut(static_vector<MotionInfo, MAX_NUM_HMVP_CANDS> &
lut.push_back(mi); lut.push_back(mi);
} }
#if JVET_O0119_BASE_PALETTE_444
void CodingStructure::resetPrevPLT(PLTBuf& prevPLT)
{
for (int comp = 0; comp < MAX_NUM_COMPONENT; comp++)
{
prevPLT.curPLTSize[comp] = 0;
memset(prevPLT.curPLT[comp], 0, MAXPLTPREDSIZE * sizeof(Pel));
}
}
void CodingStructure::reorderPrevPLT(PLTBuf& prevPLT, uint32_t curPLTSize[MAX_NUM_COMPONENT], Pel curPLT[MAX_NUM_COMPONENT][MAXPLTSIZE], bool reuseflag[MAX_NUM_COMPONENT][MAXPLTPREDSIZE], uint32_t compBegin, uint32_t NumComp, bool jointPLT)
{
Pel stuffedPLT[MAX_NUM_COMPONENT][MAXPLTPREDSIZE];
uint32_t tempCurPLTsize[MAX_NUM_COMPONENT];
uint32_t stuffPLTsize[MAX_NUM_COMPONENT];
for (int i = compBegin; i < (compBegin + NumComp); i++)
{
ComponentID comID = jointPLT ? (ComponentID)compBegin : ((i > 0) ? COMPONENT_Cb : COMPONENT_Y);
tempCurPLTsize[comID] = curPLTSize[comID];
stuffPLTsize[i] = 0;
memcpy(stuffedPLT[i], curPLT[i], curPLTSize[comID] * sizeof(Pel));
}
for (int ch = compBegin; ch < (compBegin + NumComp); ch++)
{
ComponentID comID = jointPLT ? (ComponentID)compBegin : ((ch > 0) ? COMPONENT_Cb : COMPONENT_Y);
if (ch > 1) break;
for (int i = 0; i < prevPLT.curPLTSize[comID]; i++)
{
if (tempCurPLTsize[comID] + stuffPLTsize[ch] >= MAXPLTPREDSIZE)
break;
if (!reuseflag[comID][i])
{
if (ch == COMPONENT_Y)
{
stuffedPLT[0][tempCurPLTsize[comID] + stuffPLTsize[ch]] = prevPLT.curPLT[0][i];
}
else
{
stuffedPLT[1][tempCurPLTsize[comID] + stuffPLTsize[ch]] = prevPLT.curPLT[1][i];
stuffedPLT[2][tempCurPLTsize[comID] + stuffPLTsize[ch]] = prevPLT.curPLT[2][i];
}
stuffPLTsize[ch]++;
}
}
}
for (int i = compBegin; i < (compBegin + NumComp); i++)
{
ComponentID comID = jointPLT ? (ComponentID)compBegin : ((i > 0) ? COMPONENT_Cb : COMPONENT_Y);
prevPLT.curPLTSize[comID] = curPLTSize[comID] + stuffPLTsize[comID];
memcpy(prevPLT.curPLT[i], stuffedPLT[i], prevPLT.curPLTSize[comID] * sizeof(Pel));
}
}
#endif
void CodingStructure::rebindPicBufs() void CodingStructure::rebindPicBufs()
{ {
CHECK( parent, "rebindPicBufs can only be used for the top level CodingStructure" ); CHECK( parent, "rebindPicBufs can only be used for the top level CodingStructure" );
...@@ -732,6 +806,10 @@ void CodingStructure::createCoeffs() ...@@ -732,6 +806,10 @@ void CodingStructure::createCoeffs()
m_coeffs[i] = _area > 0 ? ( TCoeff* ) xMalloc( TCoeff, _area ) : nullptr; m_coeffs[i] = _area > 0 ? ( TCoeff* ) xMalloc( TCoeff, _area ) : nullptr;
m_pcmbuf[i] = _area > 0 ? ( Pel* ) xMalloc( Pel, _area ) : nullptr; m_pcmbuf[i] = _area > 0 ? ( Pel* ) xMalloc( Pel, _area ) : nullptr;
#if JVET_O0119_BASE_PALETTE_444
m_runType[i] = _area > 0 ? (bool*)xMalloc( bool, _area) : nullptr;
m_runLength[i] = _area > 0 ? (Pel*) xMalloc( Pel, _area) : nullptr;
#endif
} }
} }
...@@ -741,6 +819,10 @@ void CodingStructure::destroyCoeffs() ...@@ -741,6 +819,10 @@ void CodingStructure::destroyCoeffs()
{ {
if( m_coeffs[i] ) { xFree( m_coeffs[i] ); m_coeffs[i] = nullptr; } if( m_coeffs[i] ) { xFree( m_coeffs[i] ); m_coeffs[i] = nullptr; }
if( m_pcmbuf[i] ) { xFree( m_pcmbuf[i] ); m_pcmbuf[i] = nullptr; } if( m_pcmbuf[i] ) { xFree( m_pcmbuf[i] ); m_pcmbuf[i] = nullptr; }
#if JVET_O0119_BASE_PALETTE_444
if (m_runType[i]) { xFree(m_runType[i]); m_runType[i] = nullptr; }
if (m_runLength[i]) { xFree(m_runLength[i]); m_runLength[i] = nullptr; }
#endif
} }
} }
...@@ -784,6 +866,10 @@ void CodingStructure::initSubStructure( CodingStructure& subStruct, const Channe ...@@ -784,6 +866,10 @@ void CodingStructure::initSubStructure( CodingStructure& subStruct, const Channe
subStruct.motionLut = motionLut; subStruct.motionLut = motionLut;
#if JVET_O0119_BASE_PALETTE_444
subStruct.prevPLT = prevPLT;
#endif
subStruct.initStructData( currQP[_chType], isLossless ); subStruct.initStructData( currQP[_chType], isLossless );
if( isTuEnc ) if( isTuEnc )
...@@ -845,6 +931,10 @@ void CodingStructure::useSubStructure( const CodingStructure& subStruct, const C ...@@ -845,6 +931,10 @@ void CodingStructure::useSubStructure( const CodingStructure& subStruct, const C
motionLut = subStruct.motionLut; motionLut = subStruct.motionLut;
} }
#if JVET_O0119_BASE_PALETTE_444
prevPLT = subStruct.prevPLT;
#endif
#if ENABLE_WPP_PARALLELISM #if ENABLE_WPP_PARALLELISM
if( nullptr == parent ) if( nullptr == parent )
...@@ -1027,6 +1117,9 @@ void CodingStructure::copyStructure( const CodingStructure& other, const Channel ...@@ -1027,6 +1117,9 @@ void CodingStructure::copyStructure( const CodingStructure& other, const Channel
motionLut = other.motionLut; motionLut = other.motionLut;
} }
#if JVET_O0119_BASE_PALETTE_444
prevPLT = other.prevPLT;
#endif
if( copyTUs ) if( copyTUs )
{ {
......
...@@ -197,6 +197,11 @@ public: ...@@ -197,6 +197,11 @@ public:
void addMiToLut(static_vector<MotionInfo, MAX_NUM_HMVP_CANDS>& lut, const MotionInfo &mi); void addMiToLut(static_vector<MotionInfo, MAX_NUM_HMVP_CANDS>& lut, const MotionInfo &mi);
#if JVET_O0119_BASE_PALETTE_444
PLTBuf prevPLT;
void resetPrevPLT(PLTBuf& prevPLT);
void reorderPrevPLT(PLTBuf& prevPLT, uint32_t curPLTSize[MAX_NUM_COMPONENT], Pel curPLT[MAX_NUM_COMPONENT][MAXPLTSIZE], bool reuseflag[MAX_NUM_COMPONENT][MAXPLTPREDSIZE], uint32_t compBegin, uint32_t NumComp, bool jointPLT);
#endif
private: private:
// needed for TU encoding // needed for TU encoding
...@@ -224,7 +229,10 @@ private: ...@@ -224,7 +229,10 @@ private:
TCoeff *m_coeffs [ MAX_NUM_COMPONENT ]; TCoeff *m_coeffs [ MAX_NUM_COMPONENT ];
Pel *m_pcmbuf [ MAX_NUM_COMPONENT ]; Pel *m_pcmbuf [ MAX_NUM_COMPONENT ];
#if JVET_O0119_BASE_PALETTE_444
bool *m_runType [MAX_NUM_COMPONENT];
Pel *m_runLength[MAX_NUM_COMPONENT];
#endif
int m_offsets[ MAX_NUM_COMPONENT ]; int m_offsets[ MAX_NUM_COMPONENT ];
MotionInfo *m_motionBuf; MotionInfo *m_motionBuf;
......
...@@ -469,6 +469,14 @@ static const int CSCALE_FP_PREC = 11; ...@@ -469,6 +469,14 @@ static const int CSCALE_FP_PREC = 11;
static const int NEIG_NUM_LOG = 6; static const int NEIG_NUM_LOG = 6;
static const int NEIG_NUM = 1 << NEIG_NUM_LOG; static const int NEIG_NUM = 1 << NEIG_NUM_LOG;
#endif #endif
#if JVET_O0119_BASE_PALETTE_444
static const int MAXPLTPREDSIZE = 63;
static const int MAXPLTSIZE = 31;
static const int PLT_RUN_MSB_IDX_CABAC_BYPASS_THRE = 4;
static const int PLT_RUN_MSB_IDX_CTX_T1 = 1;
static const int PLT_RUN_MSB_IDX_CTX_T2 = 3;
static const int PLT_FAST_RATIO = 100;
#endif
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS #if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
static const int EPBIN_WEIGHT_FACTOR = 4; static const int EPBIN_WEIGHT_FACTOR = 4;
#endif #endif
......
...@@ -679,6 +679,48 @@ const CtxSet ContextSetCfg::LFNSTIdx = ContextSetCfg::addCtxSet ...@@ -679,6 +679,48 @@ const CtxSet ContextSetCfg::LFNSTIdx = ContextSetCfg::addCtxSet
{ 8, 8, }, { 8, 8, },
} ); } );
#if JVET_O0119_BASE_PALETTE_444
const CtxSet ContextSetCfg::PLTFlag = ContextSetCfg::addCtxSet
({
{ 146 },
{ 146 },
{ 147 },
{ 1 }
});
const CtxSet ContextSetCfg::RotationFlag = ContextSetCfg::addCtxSet
({
{ 153 },
{ 138 },
{ 168 },
{ 5 }
});
const CtxSet ContextSetCfg::RunTypeFlag = ContextSetCfg::addCtxSet
({
{ 167 },
{ 167 },
{ 167 },
{ 8 }
});
const CtxSet ContextSetCfg::IdxRunModel = ContextSetCfg::addCtxSet
({
{ 157, 169, 138, 170, 155 },
{ 186, 169, 166, 186, 185 },
{ 155, 168, 167, 155, 154 },
{ 5, 6, 5, 9, 10 }
});
const CtxSet ContextSetCfg::CopyRunModel = ContextSetCfg::addCtxSet
({
{ 187, 172, 156 },
{ 187, 187, 185 },
{ 201, 171, 155 },
{ 0, 5, 5 }
});
#endif
const CtxSet ContextSetCfg::RdpcmFlag = ContextSetCfg::addCtxSet const CtxSet ContextSetCfg::RdpcmFlag = ContextSetCfg::addCtxSet
({ ({
{ CNU, CNU, }, { CNU, CNU, },
...@@ -905,6 +947,9 @@ const unsigned ContextSetCfg::NumberOfContexts = (unsigned)ContextSetCfg::sm_Ini ...@@ -905,6 +947,9 @@ const unsigned ContextSetCfg::NumberOfContexts = (unsigned)ContextSetCfg::sm_Ini
// combined sets // combined sets
#if JVET_O0119_BASE_PALETTE_444
const CtxSet ContextSetCfg::Palette = { ContextSetCfg::RotationFlag, ContextSetCfg::RunTypeFlag, ContextSetCfg::IdxRunModel, ContextSetCfg::CopyRunModel };
#endif
const CtxSet ContextSetCfg::Sao = { ContextSetCfg::SaoMergeFlag, ContextSetCfg::SaoTypeIdx }; const CtxSet ContextSetCfg::Sao = { ContextSetCfg::SaoMergeFlag, ContextSetCfg::SaoTypeIdx };
const CtxSet ContextSetCfg::Alf = { ContextSetCfg::ctbAlfFlag, ContextSetCfg::AlfUseLatestFilt, ContextSetCfg::AlfUseTemporalFilt }; const CtxSet ContextSetCfg::Alf = { ContextSetCfg::ctbAlfFlag, ContextSetCfg::AlfUseLatestFilt, ContextSetCfg::AlfUseTemporalFilt };
......
...@@ -248,6 +248,13 @@ public: ...@@ -248,6 +248,13 @@ public:
static const CtxSet MTSIndex; static const CtxSet MTSIndex;
static const CtxSet TransquantBypassFlag; static const CtxSet TransquantBypassFlag;
static const CtxSet LFNSTIdx; static const CtxSet LFNSTIdx;
#if JVET_O0119_BASE_PALETTE_444
static const CtxSet PLTFlag;
static const CtxSet RotationFlag;
static const CtxSet RunTypeFlag;
static const CtxSet IdxRunModel;
static const CtxSet CopyRunModel;
#endif
static const CtxSet RdpcmFlag; static const CtxSet RdpcmFlag;
static const CtxSet RdpcmDir; static const CtxSet RdpcmDir;
static const CtxSet SbtFlag; static const CtxSet SbtFlag;
...@@ -274,6 +281,9 @@ public: ...@@ -274,6 +281,9 @@ public:
// NOTE: The contained CtxSet's should directly follow each other in the initalization list; // NOTE: The contained CtxSet's should directly follow each other in the initalization list;
// otherwise, you will copy more elements than you want !!! // otherwise, you will copy more elements than you want !!!
static const CtxSet Sao; static const CtxSet Sao;
#if JVET_O0119_BASE_PALETTE_444
static const CtxSet Palette;
#endif
public: public:
static const std::vector<uint8_t>& getInitTable( unsigned initId ); static const std::vector<uint8_t>& getInitTable( unsigned initId );
......
...@@ -175,6 +175,10 @@ void IntraPrediction::destroy() ...@@ -175,6 +175,10 @@ void IntraPrediction::destroy()
m_piTemp = nullptr; m_piTemp = nullptr;
delete[] m_pMdlmTemp; delete[] m_pMdlmTemp;
m_pMdlmTemp = nullptr; m_pMdlmTemp = nullptr;
#if JVET_O0119_BASE_PALETTE_444
if (m_runTypeRD) { xFree(m_runTypeRD); m_runTypeRD = NULL; }
if (m_runLengthRD) { xFree(m_runLengthRD); m_runLengthRD = NULL; }
#endif
} }
void IntraPrediction::init(ChromaFormat chromaFormatIDC, const unsigned bitDepthY) void IntraPrediction::init(ChromaFormat chromaFormatIDC, const unsigned bitDepthY)
...@@ -226,6 +230,10 @@ void IntraPrediction::init(ChromaFormat chromaFormatIDC, const unsigned bitDepth ...@@ -226,6 +230,10 @@ void IntraPrediction::init(ChromaFormat chromaFormatIDC, const unsigned bitDepth
{ {
m_pMdlmTemp = new Pel[(2 * MAX_CU_SIZE + 1)*(2 * MAX_CU_SIZE + 1)];//MDLM will use top-above and left-below samples. m_pMdlmTemp = new Pel[(2 * MAX_CU_SIZE + 1)*(2 * MAX_CU_SIZE + 1)];//MDLM will use top-above and left-below samples.
} }
#if JVET_O0119_BASE_PALETTE_444
m_runTypeRD = (bool*)xMalloc(bool, MAX_CU_SIZE*MAX_CU_SIZE);
m_runLengthRD = (Pel*)xMalloc(Pel, MAX_CU_SIZE*MAX_CU_SIZE);
#endif
} }
// ==================================================================================================================== // ====================================================================================================================
...@@ -1928,4 +1936,150 @@ void IntraPrediction::predIntraMip( const ComponentID compId, PelBuf &piPred, co ...@@ -1928,4 +1936,150 @@ void IntraPrediction::predIntraMip( const ComponentID compId, PelBuf &piPred, co
m_matrixIntraPred.predBlock( pu.Y(), pu.intraDir[CHANNEL_TYPE_LUMA], piPred, bitDepth ); m_matrixIntraPred.predBlock( pu.Y(), pu.intraDir[CHANNEL_TYPE_LUMA], piPred, bitDepth );
} }
#if JVET_O0119_BASE_PALETTE_444
bool IntraPrediction::calCopyRun(CodingStructure &cs, Partitioner& partitioner, uint32_t uiStartPos, uint32_t uiTotal, uint32_t &uiRun, ComponentID compBegin)
{
CodingUnit &cu = *cs.getCU(partitioner.chType);
TransformUnit &tu = *cs.getTU(partitioner.chType);
PelBuf curPLTIdx = tu.getcurPLTIdx(compBegin);
PLTtypeBuf runType = tu.getrunType(compBegin);
uint32_t uiIdx = uiStartPos;
uint32_t uiX;
uint32_t uiY;
bool valid = false;
uiRun = 0;
while (uiIdx < uiTotal)
{
uiX = m_puiScanOrder[uiIdx].x;
uiY = m_puiScanOrder[uiIdx].y;
runType.at(uiX, uiY) = PLT_RUN_COPY;
if (uiY == 0 && !cu.useRotation[compBegin])
{
return false;
}
if (uiX == 0 && cu.useRotation[compBegin])
{
return false;
}
if (!cu.useRotation[compBegin] && curPLTIdx.at(uiX, uiY) == curPLTIdx.at(uiX, uiY - 1))
{
uiRun++;
valid = true;
}
else if (cu.useRotation[compBegin] && curPLTIdx.at(uiX, uiY) == curPLTIdx.at(uiX - 1, uiY))
{
uiRun++;
valid = true;
}
else
{
break;
}
uiIdx++;
}
return valid;
}
bool IntraPrediction::calIndexRun(CodingStructure &cs, Partitioner& partitioner, uint32_t uiStartPos, uint32_t uiTotal, uint32_t &uiRun, ComponentID compBegin)
{
TransformUnit &tu = *cs.getTU(partitioner.chType);
PelBuf curPLTIdx = tu.getcurPLTIdx(compBegin);
PLTtypeBuf runType = tu.getrunType(compBegin);
uiRun = 1;
uint32_t uiIdx = uiStartPos;
while (uiIdx < uiTotal)
{
uint32_t uiX = m_puiScanOrder[uiIdx].x;
uint32_t uiY = m_puiScanOrder[uiIdx].y;
runType.at(uiX, uiY) = PLT_RUN_INDEX;
uint32_t uiXprev = uiIdx == 0 ? 0 : m_puiScanOrder[uiIdx - 1].x;
uint32_t uiYprev = uiIdx == 0 ? 0 : m_puiScanOrder[uiIdx - 1].y;
if (uiIdx > uiStartPos && curPLTIdx.at(uiX, uiY) == curPLTIdx.at(uiXprev, uiYprev))
{
uiRun++;
}
else if (uiIdx > uiStartPos)
{
break;
}
uiIdx++;
}
return true;
}
void IntraPrediction::reorderPLT(CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t NumComp)
{
CodingUnit &cu = *cs.getCU(partitioner.chType);
uint32_t reusePLTSizetmp = 0;
uint32_t PLTSizetmp = 0;
Pel curPLTtmp[MAX_NUM_COMPONENT][MAXPLTSIZE];
bool curPLTpred[MAXPLTPREDSIZE];
for (int idx = 0; idx < MAXPLTPREDSIZE; idx++)
{
curPLTpred[idx] = false;
cu.reuseflag[compBegin][idx] = false;
}
for (int idx = 0; idx < MAXPLTSIZE; idx++)
{
curPLTpred[idx] = false;
}
for (int predidx = 0; predidx < cs.prevPLT.curPLTSize[compBegin]; predidx++)
{