diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp index b70d4ff68c28e8bcec5af966a8f8db4559ae2a70..df9ba3d1b12e0e657694dd2709cef24fa0664a37 100644 --- a/source/App/EncoderApp/EncAppCfg.cpp +++ b/source/App/EncoderApp/EncAppCfg.cpp @@ -3849,9 +3849,6 @@ void EncAppCfg::xPrintParameter() m_useColorTrans = (m_chromaFormatIDC == CHROMA_444 && m_costMode != COST_LOSSLESS_CODING) ? m_useColorTrans : 0u; #endif msg(VERBOSE, "ACT:%d ", m_useColorTrans); -#if !JVET_Q0504_PLT_NON444 - m_PLTMode = ( m_chromaFormatIDC == CHROMA_444) ? m_PLTMode : 0u; -#endif msg(VERBOSE, "PLT:%d ", m_PLTMode); msg(VERBOSE, "IBC:%d ", m_IBCMode); msg( VERBOSE, "HashME:%d ", m_HashME ); diff --git a/source/Lib/CommonLib/IntraPrediction.cpp b/source/Lib/CommonLib/IntraPrediction.cpp index 3bb4c1b3924c5341522eaf47dd9a861d6e7712fb..a675a6f0a43b2ba3b081b13ec2248bfe6bc7c64f 100644 --- a/source/Lib/CommonLib/IntraPrediction.cpp +++ b/source/Lib/CommonLib/IntraPrediction.cpp @@ -1943,10 +1943,8 @@ void IntraPrediction::reorderPLT(CodingStructure& cs, Partitioner& partitioner, for (curidx = 0; curidx < cu.curPLTSize[compBegin]; curidx++) { -#if JVET_Q0504_PLT_NON444 if( curPLTpred[curidx] ) continue; -#endif bool matchTmp = true; for (int comp = compBegin; comp < (compBegin + numComp); comp++) { @@ -1963,7 +1961,6 @@ void IntraPrediction::reorderPLT(CodingStructure& cs, Partitioner& partitioner, { cu.reuseflag[compBegin][predidx] = true; curPLTpred[curidx] = true; -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) { cu.reuseflag[COMPONENT_Y][predidx] = true; @@ -1974,14 +1971,11 @@ void IntraPrediction::reorderPLT(CodingStructure& cs, Partitioner& partitioner, } else { -#endif for (int comp = compBegin; comp < (compBegin + numComp); comp++) { curPLTtmp[comp][reusePLTSizetmp] = cs.prevPLT.curPLT[comp][predidx]; } -#if JVET_Q0504_PLT_NON444 } -#endif reusePLTSizetmp++; pltSizetmp++; } @@ -1991,7 +1985,6 @@ void IntraPrediction::reorderPLT(CodingStructure& cs, Partitioner& partitioner, { if (!curPLTpred[curidx]) { -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) { for( int comp = compBegin; comp < (compBegin + numComp); comp++ ) @@ -2010,21 +2003,17 @@ void IntraPrediction::reorderPLT(CodingStructure& cs, Partitioner& partitioner, } else { -#endif for (int comp = compBegin; comp < (compBegin + numComp); comp++) { curPLTtmp[comp][pltSizetmp] = cu.curPLT[comp][curidx]; } -#if JVET_Q0504_PLT_NON444 } -#endif pltSizetmp++; } } assert(pltSizetmp == cu.curPLTSize[compBegin]); for (int curidx = 0; curidx < cu.curPLTSize[compBegin]; curidx++) { -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) { for( int comp = COMPONENT_Y; comp < MAX_NUM_COMPONENT; comp++ ) @@ -2034,14 +2023,11 @@ void IntraPrediction::reorderPLT(CodingStructure& cs, Partitioner& partitioner, } else { -#endif for (int comp = compBegin; comp < (compBegin + numComp); comp++) { cu.curPLT[comp][curidx] = curPLTtmp[comp][curidx]; } -#if JVET_Q0504_PLT_NON444 } -#endif } } //! \} diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index 9de7347f19a6a296e7f3aa4d8d3522f9c432342f..7fbdee4f09f392d41e02e448df21dc871523b2e5 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -3224,11 +3224,7 @@ protected: Picture* xGetRefPic( PicList& rcListPic, int poc, const int layerId ); Picture* xGetLongTermRefPic( PicList& rcListPic, int poc, bool pocHasMsb, const int layerId ); public: -#if JVET_Q0504_PLT_NON444 std::unordered_map< Position, std::unordered_map< Size, double> > m_mapPltCost[2]; -#else - std::unordered_map< Position, std::unordered_map< Size, double> > m_mapPltCost; -#endif private: };// END CLASS DEFINITION Slice diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index ff73948c03e771e4a29ff209e27ce1807e356a37..417dfbada277de00cc0b76ff2b783913bf0b6eb6 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -99,7 +99,6 @@ -#define JVET_Q0504_PLT_NON444 1 // JVET-Q0504: enable palette mode for non 444 color format #define JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL 1 // JVET-Q0183: Signal the max block size in SPS and conditionally signal min_qp_prime_ts_minus4 diff --git a/source/Lib/CommonLib/Unit.cpp b/source/Lib/CommonLib/Unit.cpp index 03b0cf861927dee870906902dcbbf9d0c7194968..35b69031af88df6b711dee7dfc8f8c0eee678504 100644 --- a/source/Lib/CommonLib/Unit.cpp +++ b/source/Lib/CommonLib/Unit.cpp @@ -378,12 +378,10 @@ const bool CodingUnit::isSepTree() const return treeType != TREE_D || CS::isDualITree( *cs ); } -#if JVET_Q0504_PLT_NON444 const bool CodingUnit::isLocalSepTree() const { return treeType != TREE_D && !CS::isDualITree(*cs); } -#endif const bool CodingUnit::checkCCLMAllowed() const { diff --git a/source/Lib/CommonLib/Unit.h b/source/Lib/CommonLib/Unit.h index c867c38725db9ba2f95abcea75fc0cb637b7e4c7..9d115c6b358bd551d8670f0c1047bcf50a39c057 100644 --- a/source/Lib/CommonLib/Unit.h +++ b/source/Lib/CommonLib/Unit.h @@ -371,9 +371,7 @@ struct CodingUnit : public UnitArea const uint8_t checkAllowedSbt() const; const bool checkCCLMAllowed() const; const bool isSepTree() const; -#if JVET_Q0504_PLT_NON444 const bool isLocalSepTree() const; -#endif const bool isConsInter() const { return modeType == MODE_TYPE_INTER; } const bool isConsIntra() const { return modeType == MODE_TYPE_INTRA; } }; diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index 666c0823b2d565cebbe198c22d16ee9182e13fc6..78b8c5afe8f94de58fbcc9b050218ebd8d3ed7cd 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -671,7 +671,6 @@ void CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU bool jointPLT = false; if (cu.isSepTree()) { -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) { compBegin = COMPONENT_Y; @@ -680,7 +679,6 @@ void CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU } else { -#endif if (isLuma(partitioner.chType)) { compBegin = COMPONENT_Y; @@ -691,18 +689,12 @@ void CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU compBegin = COMPONENT_Cb; numComp = 2; } -#if JVET_Q0504_PLT_NON444 } -#endif } else { compBegin = COMPONENT_Y; -#if JVET_Q0504_PLT_NON444 numComp = (cu.chromaFormat != CHROMA_400) ? 3 : 1; -#else - numComp = 3; -#endif jointPLT = true; } if (CU::isPLT(cu)) @@ -871,7 +863,6 @@ void CABACReader::coding_unit( CodingUnit &cu, Partitioner &partitioner, CUCtx& } else { -#if JVET_Q0504_PLT_NON444 if( cu.chromaFormat != CHROMA_400 ) { cu_palette_info(cu, COMPONENT_Y, 3, cuCtx); @@ -880,9 +871,6 @@ void CABACReader::coding_unit( CodingUnit &cu, Partitioner &partitioner, CUCtx& { cu_palette_info(cu, COMPONENT_Y, 1, cuCtx); } -#else - cu_palette_info(cu, COMPONENT_Y, 3, cuCtx); -#endif } end_of_ctu(cu, cuCtx); return; @@ -1702,10 +1690,8 @@ void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_ TransformUnit& tu = *cu.firstTU; int curPLTidx = 0; -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) cu.cs->prevPLT.curPLTSize[compBegin] = cu.cs->prevPLT.curPLTSize[COMPONENT_Y]; -#endif cu.lastPLTSize[compBegin] = cu.cs->prevPLT.curPLTSize[compBegin]; int maxPltSize = cu.isSepTree() ? MAXPLTSIZE_DUALTREE : MAXPLTSIZE; @@ -1719,7 +1705,6 @@ void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_ { if (cu.reuseflag[compBegin][idx]) { -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) { for( int comp = COMPONENT_Y; comp < MAX_NUM_COMPONENT; comp++ ) @@ -1729,14 +1714,11 @@ void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_ } else { -#endif for (int comp = compBegin; comp < (compBegin + numComp); comp++) { cu.curPLT[comp][curPLTidx] = cu.cs->prevPLT.curPLT[comp][idx]; } -#if JVET_Q0504_PLT_NON444 } -#endif curPLTidx++; } } @@ -1748,10 +1730,8 @@ void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_ } cu.curPLTSize[compBegin] = curPLTidx + recievedPLTnum; -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) cu.curPLTSize[COMPONENT_Y] = cu.curPLTSize[compBegin]; -#endif for (int comp = compBegin; comp < (compBegin + numComp); comp++) { for (int idx = curPLTidx; idx < cu.curPLTSize[compBegin]; idx++) @@ -1759,7 +1739,6 @@ void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_ ComponentID compID = (ComponentID)comp; const int channelBitDepth = sps.getBitDepth(toChannelType(compID)); cu.curPLT[compID][idx] = m_BinDecoder.decodeBinsEP(channelBitDepth); -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) { if( isLuma( cu.chType ) ) @@ -1772,7 +1751,6 @@ void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_ cu.curPLT[COMPONENT_Y][idx] = 1 << (cu.cs->sps->getBitDepth(CHANNEL_TYPE_LUMA) - 1); } } -#endif } } cu.useEscape[compBegin] = true; @@ -1995,10 +1973,8 @@ void CABACReader::xDecodePLTPredIndicator(CodingUnit& cu, uint32_t maxPLTSize, C idx += symbol - 1; } cu.reuseflag[compBegin][idx] = 1; -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) cu.reuseflag[COMPONENT_Y][idx] = 1; -#endif numPltPredicted++; idx++; } diff --git a/source/Lib/DecoderLib/DecCu.cpp b/source/Lib/DecoderLib/DecCu.cpp index 35677c7d9278133dfd3f11367dde2e3ea95e104e..deae78e39b705013813aa4a7ab2caa247729d35d 100644 --- a/source/Lib/DecoderLib/DecCu.cpp +++ b/source/Lib/DecoderLib/DecCu.cpp @@ -519,7 +519,6 @@ void DecCu::xReconIntraQT( CodingUnit &cu ) } else { -#if JVET_Q0504_PLT_NON444 if( cu.chromaFormat != CHROMA_400 ) { xReconPLT(cu, COMPONENT_Y, 3); @@ -528,9 +527,6 @@ void DecCu::xReconIntraQT( CodingUnit &cu ) { xReconPLT(cu, COMPONENT_Y, 1); } -#else - xReconPLT(cu, COMPONENT_Y, 3); -#endif } return; } diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index 7f8f3b8a2bc9547e95b5cbf2d8823bd11bef8975..eeb92bb98a63ec53c08c444ad877491ddcd878f8 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -1992,18 +1992,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) pcSPS->setUseColorTrans(false); } #endif -#if JVET_Q0504_PLT_NON444 READ_FLAG( uiCode, "sps_palette_enabled_flag"); pcSPS->setPLTMode ( uiCode != 0 ); -#else - if (pcSPS->getChromaFormatIdc() == CHROMA_444) - { - READ_FLAG( uiCode, "sps_palette_enabled_flag"); pcSPS->setPLTMode ( uiCode != 0 ); - } - else - { - pcSPS->setPLTMode(false); - } -#endif #if JVET_Q0820_ACT #if JVET_Q0265 if (chromaArrayType == CHROMA_444 && pcSPS->getLog2MaxTbSize() != 6) diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index 1583815f1c3e429d9f4e5bb8733f410e81fa985d..81231e87a110a963fcd82b0ea2c8f8c3fb3283d5 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -693,7 +693,6 @@ void CABACWriter::coding_unit( const CodingUnit& cu, Partitioner& partitioner, C } else { -#if JVET_Q0504_PLT_NON444 if( cu.chromaFormat != CHROMA_400 ) { cu_palette_info(cu, COMPONENT_Y, 3, cuCtx); @@ -702,9 +701,6 @@ void CABACWriter::coding_unit( const CodingUnit& cu, Partitioner& partitioner, C { cu_palette_info(cu, COMPONENT_Y, 1, cuCtx); } -#else - cu_palette_info(cu, COMPONENT_Y, 3, cuCtx); -#endif } end_of_ctu(cu, cuCtx); return; diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index 9824d1a0d5ac7715bcf30381936fdbf3820a64fe..766342840982c8fff33551b9c5d89c0ae8ebeafa 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -321,12 +321,8 @@ void EncCu::compressCtu( CodingStructure& cs, const UnitArea& area, const unsign m_modeCtrl->initCTUEncoding( *cs.slice ); cs.treeType = TREE_D; -#if JVET_Q0504_PLT_NON444 cs.slice->m_mapPltCost[0].clear(); cs.slice->m_mapPltCost[1].clear(); -#else - cs.slice->m_mapPltCost.clear(); -#endif #if ENABLE_SPLIT_PARALLELISM if( m_pcEncCfg->getNumSplitThreads() > 1 ) { @@ -400,12 +396,8 @@ void EncCu::compressCtu( CodingStructure& cs, const UnitArea& area, const unsign tempCS->prevQP[CH_L] = bestCS->prevQP[CH_L] = prevQP[CH_L]; xCompressCU(tempCS, bestCS, partitioner); -#if JVET_Q0504_PLT_NON444 cs.slice->m_mapPltCost[0].clear(); cs.slice->m_mapPltCost[1].clear(); -#else - cs.slice->m_mapPltCost.clear(); -#endif // all signals were already copied during compression if the CTU was split - at this point only the structures are copied to the top level CS const bool copyUnsplitCTUSignals = bestCS->cus.size() == 1; cs.useSubStructure(*bestCS, partitioner.chType, CS::getArea(*bestCS, area, partitioner.chType), copyUnsplitCTUSignals, @@ -620,7 +612,6 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par bool jointPLT = false; if (partitioner.isSepTree( *tempCS )) { -#if JVET_Q0504_PLT_NON444 if( !CS::isDualITree(*tempCS) && partitioner.treeType != TREE_D ) { compBegin = COMPONENT_Y; @@ -629,7 +620,6 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par } else { -#endif if (isLuma(partitioner.chType)) { compBegin = COMPONENT_Y; @@ -640,18 +630,12 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par compBegin = COMPONENT_Cb; numComp = 2; } -#if JVET_Q0504_PLT_NON444 } -#endif } else { compBegin = COMPONENT_Y; -#if JVET_Q0504_PLT_NON444 numComp = (tempCS->area.chromaFormat != CHROMA_400) ? 3 : 1; -#else - numComp = 3; -#endif jointPLT = true; } SplitSeries splitmode = -1; @@ -2087,7 +2071,6 @@ void EncCu::xCheckPLT(CodingStructure *&tempCS, CodingStructure *&bestCS, Partit } else { -#if JVET_Q0504_PLT_NON444 if( cu.chromaFormat != CHROMA_400 ) { m_pcIntraSearch->PLTSearch(*tempCS, partitioner, COMPONENT_Y, 3); @@ -2096,9 +2079,6 @@ void EncCu::xCheckPLT(CodingStructure *&tempCS, CodingStructure *&bestCS, Partit { m_pcIntraSearch->PLTSearch(*tempCS, partitioner, COMPONENT_Y, 1); } -#else - m_pcIntraSearch->PLTSearch(*tempCS, partitioner, COMPONENT_Y, 3); -#endif } @@ -2128,7 +2108,6 @@ void EncCu::xCheckPLT(CodingStructure *&tempCS, CodingStructure *&bestCS, Partit } else { -#if JVET_Q0504_PLT_NON444 if( cu.chromaFormat != CHROMA_400 ) { m_CABACEstimator->cu_palette_info(cu, COMPONENT_Y, 3, cuCtx); @@ -2137,9 +2116,6 @@ void EncCu::xCheckPLT(CodingStructure *&tempCS, CodingStructure *&bestCS, Partit { m_CABACEstimator->cu_palette_info(cu, COMPONENT_Y, 1, cuCtx); } -#else - m_CABACEstimator->cu_palette_info(cu, COMPONENT_Y, 3, cuCtx); -#endif } tempCS->fracBits = m_CABACEstimator->getEstFracBits(); tempCS->cost = m_pcRdCost->calcRdCost(tempCS->fracBits, tempCS->dist); @@ -2153,11 +2129,7 @@ void EncCu::xCheckPLT(CodingStructure *&tempCS, CodingStructure *&bestCS, Partit tempCS->useDbCost = m_pcEncCfg->getUseEncDbOpt(); const Area currCuArea = cu.block(getFirstComponentOfChannel(partitioner.chType)); -#if JVET_Q0504_PLT_NON444 cu.slice->m_mapPltCost[isChroma(partitioner.chType)][currCuArea.pos()][currCuArea.size()] = tempCS->cost; -#else - cu.slice->m_mapPltCost[currCuArea.pos()][currCuArea.size()] = tempCS->cost; -#endif #if WCG_EXT DTRACE_MODE_COST(*tempCS, m_pcRdCost->getLambda(true)); #else diff --git a/source/Lib/EncoderLib/EncModeCtrl.cpp b/source/Lib/EncoderLib/EncModeCtrl.cpp index 3259b10d683b4d684f274d26f980010c9cc6c65a..1404f4aaee6e2f2e5cef1f943878091db7384a51 100644 --- a/source/Lib/EncoderLib/EncModeCtrl.cpp +++ b/source/Lib/EncoderLib/EncModeCtrl.cpp @@ -1324,20 +1324,12 @@ void EncModeCtrlMTnoRQT::initCULevel( Partitioner &partitioner, const CodingStru // add intra modes if( tryIntraRdo ) { -#if JVET_Q0504_PLT_NON444 if (cs.slice->getSPS()->getPLTMode() && (partitioner.treeType != TREE_D || cs.slice->isIRAP() || (cs.area.lwidth() == 4 && cs.area.lheight() == 4)) && getPltEnc()) -#else - if (cs.slice->getSPS()->getPLTMode() && ( cs.slice->isIRAP() || (cs.area.lwidth() == 4 && cs.area.lheight() == 4) ) && getPltEnc() ) -#endif { m_ComprCUCtxList.back().testModes.push_back({ ETM_PALETTE, ETO_STANDARD, qp }); } m_ComprCUCtxList.back().testModes.push_back( { ETM_INTRA, ETO_STANDARD, qp } ); -#if JVET_Q0504_PLT_NON444 if (cs.slice->getSPS()->getPLTMode() && partitioner.treeType == TREE_D && !cs.slice->isIRAP() && !(cs.area.lwidth() == 4 && cs.area.lheight() == 4) && getPltEnc()) -#else - if (cs.slice->getSPS()->getPLTMode() && !cs.slice->isIRAP() && !(cs.area.lwidth() == 4 && cs.area.lheight() == 4) && getPltEnc() ) -#endif { m_ComprCUCtxList.back().testModes.push_back({ ETM_PALETTE, ETO_STANDARD, qp }); } @@ -1578,11 +1570,7 @@ bool EncModeCtrlMTnoRQT::tryMode( const EncTestMode& encTestmode, const CodingSt } } } -#if JVET_Q0504_PLT_NON444 if (bestMode.type == ETM_PALETTE && !slice.isIRAP() && partitioner.treeType == TREE_D && !(partitioner.currArea().lumaSize().width == 4 && partitioner.currArea().lumaSize().height == 4)) // inter slice -#else - if (bestMode.type == ETM_PALETTE && !slice.isIRAP() && !( partitioner.currArea().lumaSize().width == 4 && partitioner.currArea().lumaSize().height == 4) ) // inter slice -#endif { return false; } @@ -1607,11 +1595,7 @@ bool EncModeCtrlMTnoRQT::tryMode( const EncTestMode& encTestmode, const CodingSt const Area curr_cu = CS::getArea(cs, cs.area, partitioner.chType).blocks[getFirstComponentOfChannel(partitioner.chType)]; try { -#if JVET_Q0504_PLT_NON444 double stored_cost = slice.m_mapPltCost[isChroma(partitioner.chType)].at(curr_cu.pos()).at(curr_cu.size()); -#else - double stored_cost = slice.m_mapPltCost.at(curr_cu.pos()).at(curr_cu.size()); -#endif if (bestMode.type != ETM_INVALID && stored_cost > cuECtx.bestCS->cost) { return false; diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp index 7f694c62be867e92d48fb153de94159c7ee4f1ff..09b36bd768ac6ddef7ec253751e584fc4554fe13 100644 --- a/source/Lib/EncoderLib/IntraSearch.cpp +++ b/source/Lib/EncoderLib/IntraSearch.cpp @@ -1589,10 +1589,8 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo cs.getPredBuf().copyFrom(cs.getOrgBuf()); cs.getPredBuf().Y().rspSignal(m_pcReshape->getFwdLUT()); } -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) cs.prevPLT.curPLTSize[compBegin] = cs.prevPLT.curPLTSize[COMPONENT_Y]; -#endif cu.lastPLTSize[compBegin] = cs.prevPLT.curPLTSize[compBegin]; //derive palette derivePLTLossy(cs, partitioner, compBegin, numComp); @@ -1635,7 +1633,6 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo Pel curPLTtmp[MAX_NUM_COMPONENT][MAXPLTSIZE]; int reuseFlagIdx = 0, curPLTtmpIdx = 0, reuseEntrySize = 0; memset(cu.reuseflag[compBegin], false, sizeof(bool) * MAXPLTPREDSIZE); -#if JVET_Q0504_PLT_NON444 int compBeginTmp = compBegin; int numCompTmp = numComp; if( cu.isLocalSepTree() ) @@ -1644,16 +1641,11 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo compBeginTmp = COMPONENT_Y; numCompTmp = (cu.chromaFormat != CHROMA_400) ? 3 : 1; } -#endif for (int curIdx = 0; curIdx < cu.curPLTSize[compBegin]; curIdx++) { if (idxExist[curIdx]) { -#if JVET_Q0504_PLT_NON444 for (int comp = compBeginTmp; comp < (compBeginTmp + numCompTmp); comp++) -#else - for (int comp = compBegin; comp < (compBegin + numComp); comp++) -#endif curPLTtmp[comp][curPLTtmpIdx] = cu.curPLT[comp][curIdx]; // Update reuse flags @@ -1676,10 +1668,8 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo if (match) { cu.reuseflag[compBegin][reuseFlagIdx] = true; -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) cu.reuseflag[COMPONENT_Y][reuseFlagIdx] = true; -#endif reuseEntrySize++; } } @@ -1689,13 +1679,9 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo cu.reusePLTSize[compBegin] = reuseEntrySize; // update palette table cu.curPLTSize[compBegin] = newPLTSize; -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) cu.curPLTSize[COMPONENT_Y] = newPLTSize; for (int comp = compBeginTmp; comp < (compBeginTmp + numCompTmp); comp++) -#else - for (int comp = compBegin; comp < (compBegin + numComp); comp++) -#endif memcpy( cu.curPLT[comp], curPLTtmp[comp], sizeof(Pel)*cu.curPLTSize[compBegin]); } #endif @@ -2505,7 +2491,6 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, uint32_t scaleX = getComponentScaleX(COMPONENT_Cb, cs.sps->getChromaFormatIdc()); uint32_t scaleY = getComponentScaleY(COMPONENT_Cb, cs.sps->getChromaFormatIdc()); -#if JVET_Q0504_PLT_NON444 for (uint32_t y = 0; y < height; y++) { for (uint32_t x = 0; x < width; x++) @@ -2604,78 +2589,13 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, } } } -#else - for (uint32_t y = 0; y < height; y++) - { - for (uint32_t x = 0; x < width; x++) - { - uint32_t org[3], pX, pY; - for (int comp = compBegin; comp < (compBegin + numComp); comp++) - { - pX = (comp > 0 && compBegin == COMPONENT_Y) ? (x >> scaleX) : x; - pY = (comp > 0 && compBegin == COMPONENT_Y) ? (y >> scaleY) : y; - org[comp] = orgBuf[comp].at(pX, pY); - } - element.setAll(org, compBegin, numComp); - int besti = last, bestSAD = (last == -1) ? MAX_UINT : pelList[last].getSAD(element, cs.sps->getBitDepths(), compBegin, numComp, lossless); - if (lossless) - { - if (bestSAD) - { - for (int i = idx - 1; i >= 0; i--) - { - uint32_t sad = pelList[i].getSAD(element, cs.sps->getBitDepths(), compBegin, numComp, lossless); - if (sad == 0) - { - bestSAD = sad; - besti = i; - break; - } - } - } - } - else - { - if (bestSAD) - { - for (int i = idx - 1; i >= 0; i--) - { - uint32_t sad = pelList[i].getSAD(element, cs.sps->getBitDepths(), compBegin, numComp, lossless); - if (sad < bestSAD) - { - bestSAD = sad; - besti = i; - if (!sad) break; - } - } - } - } - if (besti >= 0 && pelList[besti].almostEqualData(element, errorLimit, cs.sps->getBitDepths(), compBegin, numComp, lossless)) - { - pelList[besti].addElement(element, compBegin, numComp); - last = besti; - } - else - { - pelList[idx].copyDataFrom(element, compBegin, numComp); - pelList[idx].setCnt(1); - last = idx; - idx++; - } - } - } -#endif for (int i = 0; i < dictMaxSize; i++) { -#if JVET_Q0504_PLT_NON444 pelListSort[i].setCnt(0, COMPONENT_Y); pelListSort[i].setCnt(0, COMPONENT_Cb); pelListSort[i].setCnt(0, COMPONENT_Cr); pelListSort[i].setCnt(0, MAX_NUM_COMPONENT); -#else - pelListSort[i].setCnt(0); -#endif pelListSort[i].resetAll(compBegin, numComp); } @@ -2683,20 +2603,12 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, dictMaxSize = 1; for (int i = 0; i < idx; i++) { -#if JVET_Q0504_PLT_NON444 if( pelList[i].getCnt(MAX_NUM_COMPONENT) > pelListSort[dictMaxSize - 1].getCnt(MAX_NUM_COMPONENT) ) -#else - if (pelList[i].getCnt() > pelListSort[dictMaxSize - 1].getCnt()) -#endif { int j; for (j = dictMaxSize; j > 0; j--) { -#if JVET_Q0504_PLT_NON444 if (pelList[i].getCnt(MAX_NUM_COMPONENT) > pelListSort[j - 1].getCnt(MAX_NUM_COMPONENT)) -#else - if (pelList[i].getCnt() > pelListSort[j - 1].getCnt() ) -#endif { pelListSort[j].copyAllFrom(pelListSort[j - 1], compBegin, numComp); dictMaxSize = std::min(dictMaxSize + 1, (uint32_t)maxPltSize); @@ -2723,7 +2635,6 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, int run; double reuseflagCost; #endif -#if JVET_Q0504_PLT_NON444 for (int i = 0; i < maxPltSize; i++) { if( pelListSort[i].getCnt(MAX_NUM_COMPONENT) ) @@ -2856,120 +2767,9 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, break; } } -#else -for (int i = 0; i < maxPltSize; i++) - { - if (pelListSort[i].getCnt()) - { - int half = pelListSort[i].getCnt() >> 1; - for (int comp = compBegin; comp < (compBegin + numComp); comp++) - { - cu.curPLT[comp][paletteSize] = (pelListSort[i].getSumData(comp) + half) / pelListSort[i].getCnt(); - } - - int best = -1; - if (errorLimit) - { - double pal[MAX_NUM_COMPONENT], err = 0.0, bestCost = 0.0; - for (int comp = compBegin; comp < (compBegin + numComp); comp++) - { - pal[comp] = pelListSort[i].getSumData(comp) / (double)pelListSort[i].getCnt(); - err = pal[comp] - cu.curPLT[comp][paletteSize]; - if (isChroma((ComponentID) comp)) - { - bestCost += (err * err * PLT_CHROMA_WEIGHTING) / (1 << (2 * pcmShiftRight_C)); - } - else - { - bestCost += (err * err) / (1 << (2 * pcmShiftRight_L)); - } - } - bestCost = bestCost * pelListSort[i].getCnt() + bitCost; - - for (int t = 0; t < cs.prevPLT.curPLTSize[compBegin]; t++) - { - double cost = 0.0; - for (int comp = compBegin; comp < (compBegin + numComp); comp++) - { - err = pal[comp] - cs.prevPLT.curPLT[comp][t]; - if (isChroma((ComponentID) comp)) - { - cost += (err * err * PLT_CHROMA_WEIGHTING) / (1 << (2 * pcmShiftRight_C)); - } - else - { - cost += (err * err) / (1 << (2 * pcmShiftRight_L)); - } - } - cost *= pelListSort[i].getCnt(); -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX - run = 0; - for (int t2 = t-1; t2 >= 0; t2--) - { - if (!reuseflag[t2]) - { - run++; - } - else - { - break; - } - } - reuseflagCost = m_pcRdCost->getLambda() / (double)(1 << (2 * plt_lambda_shift)) * getEpExGolombNumBins(run ? run + 1 : run, 0); - cost += reuseflagCost; -#endif - if (cost < bestCost) - { - best = t; - bestCost = cost; - } - } - if (best != -1) - { - for (int comp = compBegin; comp < (compBegin + numComp); comp++) - { - cu.curPLT[comp][paletteSize] = cs.prevPLT.curPLT[comp][best]; - } -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX - reuseflag[best] = true; -#endif - } - } - - bool duplicate = false; - if (pelListSort[i].getCnt() == 1 && best == -1) - { - duplicate = true; - } - else - { - for (int t = 0; t<paletteSize; t++) - { - bool duplicateTmp = true; - for (int comp = compBegin; comp < (compBegin + numComp); comp++) - { - duplicateTmp = duplicateTmp && (cu.curPLT[comp][paletteSize] == cu.curPLT[comp][t]); - } - if (duplicateTmp) - { - duplicate = true; - break; - } - } - } - if (!duplicate) paletteSize++; - } - else - { - break; - } - } -#endif cu.curPLTSize[compBegin] = paletteSize; -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) cu.curPLTSize[COMPONENT_Y] = paletteSize; -#endif delete[] pelList; delete[] pelListSort; diff --git a/source/Lib/EncoderLib/IntraSearch.h b/source/Lib/EncoderLib/IntraSearch.h index 3b5ea2aed81a4250a659d3a3b63a63b2b179e164..846b0fe683b50a6de80bf021d97e7ed4eb2c066b 100644 --- a/source/Lib/EncoderLib/IntraSearch.h +++ b/source/Lib/EncoderLib/IntraSearch.h @@ -72,33 +72,20 @@ public: return cnt > other.cnt; } SortingElement() { -#if JVET_Q0504_PLT_NON444 cnt[0] = cnt[1] = cnt[2] = cnt[3] = 0; shift[0] = shift[1] = shift[2] = 0; lastCnt[0] = lastCnt[1] = lastCnt[2] = 0; -#else - cnt = shift = lastCnt = 0; -#endif data[0] = data[1] = data[2] = 0; sumData[0] = sumData[1] = sumData[2] = 0; } -#if JVET_Q0504_PLT_NON444 uint32_t getCnt(int idx) const { return cnt[idx]; } void setCnt(uint32_t val, int idx) { cnt[idx] = val; } -#else - uint32_t getCnt() const { return cnt; } - void setCnt(uint32_t val) { cnt = val; } -#endif int getSumData (int id) const { return sumData[id]; } void resetAll(ComponentID compBegin, uint32_t numComp) { -#if JVET_Q0504_PLT_NON444 shift[0] = shift[1] = shift[2] = 0; lastCnt[0] = lastCnt[1] = lastCnt[2] = 0; -#else - shift = lastCnt = 0; -#endif for (int ch = compBegin; ch < (compBegin + numComp); ch++) { data[ch] = 0; @@ -168,37 +155,22 @@ public: { data[comp] = element.data[comp]; sumData[comp] = data[comp]; -#if JVET_Q0504_PLT_NON444 shift[comp] = 0; lastCnt[comp] = 1; -#endif } -#if !JVET_Q0504_PLT_NON444 - shift = 0; lastCnt = 1; -#endif } void copyAllFrom(SortingElement element, ComponentID compBegin, uint32_t numComp) { copyDataFrom(element, compBegin, numComp); -#if !JVET_Q0504_PLT_NON444 - cnt = element.cnt; -#endif for (int comp = compBegin; comp < (compBegin + numComp); comp++) { sumData[comp] = element.sumData[comp]; -#if JVET_Q0504_PLT_NON444 cnt[comp] = element.cnt[comp]; shift[comp] = element.shift[comp]; lastCnt[comp] = element.lastCnt[comp]; -#endif } -#if JVET_Q0504_PLT_NON444 cnt[MAX_NUM_COMPONENT] = element.cnt[MAX_NUM_COMPONENT]; -#else - lastCnt = element.lastCnt; shift = element.shift; -#endif } -#if JVET_Q0504_PLT_NON444 void addElement(const SortingElement& element, ComponentID compBegin, uint32_t numComp) { for (int i = compBegin; i<(compBegin + numComp); i++) @@ -214,34 +186,9 @@ public: } } } -#else - void addElement(const SortingElement& element, ComponentID compBegin, uint32_t numComp) - { - cnt++; - for (int i = compBegin; i<(compBegin + numComp); i++) - { - sumData[i] += element.data[i]; - } - if (cnt>1 && cnt == 2 * lastCnt) - { - uint32_t rnd = 1 << shift; - shift++; - for (int i = compBegin; i<(compBegin + numComp); i++) - { - data[i] = (sumData[i] + rnd) >> shift; - } - lastCnt = cnt; - } - } -#endif private: -#if JVET_Q0504_PLT_NON444 uint32_t cnt[MAX_NUM_COMPONENT+1]; int shift[3], lastCnt[3], data[3], sumData[3]; -#else - uint32_t cnt; - int shift, lastCnt, data[3], sumData[3]; -#endif }; /// encoder search class #if !REMOVE_PPS_REXT diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp index 62997f5591264fde8caef3e681a1182f1538c875..b95f0e53e951679b6f299627281895bae679b044 100644 --- a/source/Lib/EncoderLib/VLCWriter.cpp +++ b/source/Lib/EncoderLib/VLCWriter.cpp @@ -1310,14 +1310,7 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_FLAG(pcSPS->getUseColorTrans() ? 1 : 0, "sps_act_enabled_flag"); } #endif -#if JVET_Q0504_PLT_NON444 WRITE_FLAG(pcSPS->getPLTMode() ? 1 : 0, "sps_palette_enabled_flag" ); -#else - if (pcSPS->getChromaFormatIdc() == CHROMA_444) - { - WRITE_FLAG(pcSPS->getPLTMode() ? 1 : 0, "sps_palette_enabled_flag" ); - } -#endif #if JVET_Q0820_ACT if (pcSPS->getChromaFormatIdc() == CHROMA_444 && pcSPS->getLog2MaxTbSize() != 6) {