diff --git a/source/Lib/CommonLib/Rom.cpp b/source/Lib/CommonLib/Rom.cpp index 6077c5916173c4d612803bf8ef55ff5c9616642c..6a3425e95954e7c0ad0e576119849717703fb024 100644 --- a/source/Lib/CommonLib/Rom.cpp +++ b/source/Lib/CommonLib/Rom.cpp @@ -453,7 +453,6 @@ void initROM() ::memset(g_isReusedUniMVsFilled, 0, sizeof(g_isReusedUniMVsFilled)); -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX for (int qp = 0; qp < 57; qp++) { int qpRem = (qp + 12) % 6; @@ -463,7 +462,6 @@ void initROM() double threshQP = ((double)(1 << quantiserRightShift)) / quantiserScale; g_paletteQuant[qp] = (int)(threshQP*0.16 + 0.5); } -#endif } void destroyROM() @@ -748,11 +746,7 @@ int16_t *g_triangleWeights[TRIANGLE_DIR_NUM][MAX_CU_DEPTH - MIN_CU_LOG2 + 2][MAX Mv g_reusedUniMVs[32][32][8][8][2][33]; bool g_isReusedUniMVsFilled[32][32][8][8]; -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX uint16_t g_paletteQuant[57]; -#else -const uint8_t g_paletteQuant[52] = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 9, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, 22, 24, 23, 25, 26, 28, 29, 31, 32, 34, 36, 37, 39, 41, 42, 45 }; -#endif uint8_t g_paletteRunTopLut [5] = { 0, 1, 1, 2, 2 }; uint8_t g_paletteRunLeftLut[5] = { 0, 1, 2, 3, 4 }; diff --git a/source/Lib/CommonLib/Rom.h b/source/Lib/CommonLib/Rom.h index ecdbdd9bc79e9645352fc21264fa241d8685064a..38c1f55ac1ebeefd328030d1b139954870c5612c 100644 --- a/source/Lib/CommonLib/Rom.h +++ b/source/Lib/CommonLib/Rom.h @@ -217,11 +217,7 @@ class Mv; extern Mv g_reusedUniMVs[32][32][8][8][2][33]; extern bool g_isReusedUniMVsFilled[32][32][8][8]; -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX extern uint16_t g_paletteQuant[57]; -#else -extern const uint8_t g_paletteQuant[52]; -#endif extern uint8_t g_paletteRunTopLut[5]; extern uint8_t g_paletteRunLeftLut[5]; diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 79608f0854aa84b6a74470af1b80ca8350d4e3b9..6b5d297041e931d18f3f32911782fc82880ab074 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -126,7 +126,6 @@ -#define JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX 1 // JVET-Q0503/Q0712: Platte encoder improvement/bugfix #define JVET_Q0819_PH_CHANGES 1 // JVET-Q0819: Combination of PH related syntax changes diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp index eb18651610495bd7b26fa8db73bce505442118da..7249f3cce0033b21480e50bcd44588f9d21c8577 100644 --- a/source/Lib/EncoderLib/IntraSearch.cpp +++ b/source/Lib/EncoderLib/IntraSearch.cpp @@ -1588,25 +1588,14 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo derivePLTLossy(cs, partitioner, compBegin, numComp); reorderPLT(cs, partitioner, compBegin, numComp); -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX bool idxExist[MAXPLTSIZE + 1] = { false }; -#endif preCalcPLTIndexRD(cs, partitioner, compBegin, numComp); // Pre-calculate distortions for each pixel double rdCost = MAX_DOUBLE; -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX deriveIndexMap(cs, partitioner, compBegin, numComp, PLT_SCAN_HORTRAV, rdCost, idxExist); // Optimize palette index map (horizontal scan) -#else - deriveIndexMap(cs, partitioner, compBegin, numComp, PLT_SCAN_HORTRAV, rdCost); // Optimize palette index map (horizontal scan) -#endif if ((cu.curPLTSize[compBegin] + cu.useEscape[compBegin]) > 1) { -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX deriveIndexMap(cs, partitioner, compBegin, numComp, PLT_SCAN_VERTRAV, rdCost, idxExist); // Optimize palette index map (vertical scan) -#else - deriveIndexMap(cs, partitioner, compBegin, numComp, PLT_SCAN_VERTRAV, rdCost); // Optimize palette index map (vertical scan) -#endif } -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX // Remove unused palette entries uint8_t newPLTSize = 0; int idxMapping[MAXPLTSIZE + 1]; @@ -1676,7 +1665,6 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo for (int comp = compBeginTmp; comp < (compBeginTmp + numCompTmp); comp++) memcpy( cu.curPLT[comp], curPLTtmp[comp], sizeof(Pel)*cu.curPLTSize[compBegin]); } -#endif cu.useRotation[compBegin] = m_bestScanRotationMode; int indexMaxSize = cu.useEscape[compBegin] ? (cu.curPLTSize[compBegin] + 1) : cu.curPLTSize[compBegin]; if (indexMaxSize <= 1) @@ -1689,9 +1677,7 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo { for (uint32_t x = 0; x < width; x++) { -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX curPLTIdx.at(x, y) = idxMapping[curPLTIdx.at(x, y)]; -#endif if (curPLTIdx.at(x, y) == cu.curPLTSize[compBegin]) { calcPixelPred(cs, partitioner, y, x, compBegin, numComp); @@ -1929,11 +1915,7 @@ void IntraSearch::preCalcPLTIndexRD(CodingStructure& cs, Partitioner& partitione } } -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX void IntraSearch::deriveIndexMap(CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp, PLTScanMode pltScanMode, double& dMinCost, bool* idxExist) -#else -void IntraSearch::deriveIndexMap(CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp, PLTScanMode pltScanMode, double& dMinCost) -#endif { CodingUnit &cu = *cs.getCU(partitioner.chType); TransformUnit &tu = *cs.getTU(partitioner.chType); @@ -2056,16 +2038,12 @@ void IntraSearch::deriveIndexMap(CodingStructure& cs, Partitioner& partitioner, { cu.useEscape[compBegin] = m_bestEscape; m_bestScanRotationMode = pltScanMode; -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX memset(idxExist, false, sizeof(bool) * (MAXPLTSIZE + 1)); -#endif for (int pos = 0; pos < (width*height); pos++) { runIndex[pos] = checkIndexTable[pos]; runType[pos] = checkRunTable[pos]; -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX idxExist[checkIndexTable[pos]] = true; -#endif } dMinCost = sumRdCost; } @@ -2229,32 +2207,16 @@ double IntraSearch::rateDistOptPLT( rdCost = MAX_DOUBLE; return rdCost; } -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX rdCost += m_pcRdCost->getLambda()*(m_truncBinBits[(runIndex > refIndex) ? runIndex - 1 : runIndex][(scanPos == 0) ? (indexMaxValue + 1) : indexMaxValue] << SCALE_BITS); -#else - rdCost += m_pcRdCost->getLambda()*m_truncBinBits[(runIndex > refIndex) ? runIndex - 1 : runIndex][(scanPos == 0) ? (indexMaxValue + 1) : indexMaxValue]; -#endif } -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX rdCost += m_indexError[runIndex][m_scanOrder[scanPos].idx] * (1 << SCALE_BITS); -#else - rdCost += m_indexError[runIndex][m_scanOrder[scanPos].idx]; -#endif if (scanPos > 0) { -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX rdCost += m_pcRdCost->getLambda()*( identityFlag ? (IndexfracBits[(dist < RUN_IDX_THRE) ? dist : RUN_IDX_THRE].intBits[1]) : (IndexfracBits[(dist < RUN_IDX_THRE) ? dist : RUN_IDX_THRE].intBits[0] ) ); -#else - rdCost += m_pcRdCost->getLambda()*( identityFlag ? (IndexfracBits[(dist < RUN_IDX_THRE) ? dist : RUN_IDX_THRE].intBits[1] >> SCALE_BITS) : (IndexfracBits[(dist < RUN_IDX_THRE) ? dist : RUN_IDX_THRE].intBits[0] >> SCALE_BITS)); -#endif } if ( !identityFlag && scanPos >= width && prevRunType != PLT_RUN_COPY ) { -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX rdCost += m_pcRdCost->getLambda()*TypefracBits.intBits[runType]; -#else - rdCost += m_pcRdCost->getLambda()*(TypefracBits.intBits[runType] >> SCALE_BITS); -#endif } if (!identityFlag || scanPos == 0) { @@ -2460,15 +2422,11 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, } } -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX TransformUnit &tu = *cs.getTU(partitioner.chType); QpParam cQP(tu, compBegin); int qp = cQP.Qp(true) - 12; qp = (qp < 0) ? 0 : ((qp > 56) ? 56 : qp); int errorLimit = g_paletteQuant[qp]; -#else - int errorLimit = g_paletteQuant[cu.qp]; -#endif if (lossless) { errorLimit = 0; @@ -2622,11 +2580,9 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, } const int plt_lambda_shift = (compBegin > 0) ? pcmShiftRight_C : pcmShiftRight_L; double bitCost = m_pcRdCost->getLambda() / (double) (1 << (2 * plt_lambda_shift)) * numColorBits; -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX bool reuseflag[MAXPLTPREDSIZE] = { false }; int run; double reuseflagCost; -#endif for (int i = 0; i < maxPltSize; i++) { if( pelListSort[i].getCnt(MAX_NUM_COMPONENT) ) @@ -2680,7 +2636,6 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, cost += (err * err) / (1 << (2 * pcmShiftRight_L)) * pelListSort[i].getCnt(comp); } } -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX run = 0; for (int t2 = t; t2 >= 0; t2--) { @@ -2695,7 +2650,6 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, } reuseflagCost = m_pcRdCost->getLambda() / (double)(1 << (2 * plt_lambda_shift)) * getEpExGolombNumBins(run ? run + 1 : run, 0); cost += reuseflagCost; -#endif if( cost < bestCost ) { @@ -2709,9 +2663,7 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, { cu.curPLT[comp][paletteSize] = cs.prevPLT.curPLT[comp][best]; } -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX reuseflag[best] = true; -#endif } } diff --git a/source/Lib/EncoderLib/IntraSearch.h b/source/Lib/EncoderLib/IntraSearch.h index 846b0fe683b50a6de80bf021d97e7ed4eb2c066b..26d947843a3a84e8adfaa18f6fbbb6f16da09024 100644 --- a/source/Lib/EncoderLib/IntraSearch.h +++ b/source/Lib/EncoderLib/IntraSearch.h @@ -482,11 +482,7 @@ protected: void calcPixelPred ( CodingStructure& cs, Partitioner& partitioner, uint32_t yPos, uint32_t xPos, ComponentID compBegin, uint32_t numComp); void preCalcPLTIndexRD (CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp); void calcPixelPredRD (CodingStructure& cs, Partitioner& partitioner, Pel* orgBuf, Pel* pixelValue, Pel* recoValue, ComponentID compBegin, uint32_t numComp); -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX void deriveIndexMap (CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp, PLTScanMode pltScanMode, double& dCost, bool* idxExist); -#else - void deriveIndexMap (CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp, PLTScanMode pltScanMode, double& dCost); -#endif bool deriveSubblockIndexMap(CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, PLTScanMode pltScanMode, int minSubPos, int maxSubPos, const BinFracBits& fracBitsPltRunType, const BinFracBits* fracBitsPltIndexINDEX, const BinFracBits* fracBitsPltIndexCOPY, const double minCost, bool useRotate); double rateDistOptPLT (bool RunType, uint8_t RunIndex, bool prevRunType, uint8_t prevRunIndex, uint8_t aboveRunIndex, bool& prevCodedRunType, int& prevCodedRunPos, int scanPos, uint32_t width, int dist, int indexMaxValue, const BinFracBits* IndexfracBits, const BinFracBits& TypefracBits); void initTBCTable (int bitDepth);