diff --git a/source/Lib/CommonLib/CodingStructure.cpp b/source/Lib/CommonLib/CodingStructure.cpp index 66d38f1c5843aae5a83064a2a22b036de0cb5506..e9ec9b9972bf1dad25b84fc675541eb42d780b0c 100644 --- a/source/Lib/CommonLib/CodingStructure.cpp +++ b/source/Lib/CommonLib/CodingStructure.cpp @@ -73,8 +73,8 @@ CodingStructure::CodingStructure(CUCache& cuCache, PUCache& puCache, TUCache& tu m_coeffs[ i ] = nullptr; m_pcmbuf[ i ] = nullptr; #if JVET_O0119_BASE_PALETTE_444 - m_runType[i] = nullptr; - m_runLength[i] = nullptr; + m_runType[i] = nullptr; + m_runLength[i] = nullptr; #endif m_offsets[ i ] = 0; diff --git a/source/Lib/CommonLib/IntraPrediction.cpp b/source/Lib/CommonLib/IntraPrediction.cpp index 552177d8fe43cef661989ab80baa8d31debe55b6..d15ead02820ef11175094240dd61c819a0967d69 100644 --- a/source/Lib/CommonLib/IntraPrediction.cpp +++ b/source/Lib/CommonLib/IntraPrediction.cpp @@ -1937,75 +1937,75 @@ void IntraPrediction::predIntraMip( const ComponentID compId, PelBuf &piPred, co } #if JVET_O0119_BASE_PALETTE_444 -bool IntraPrediction::calCopyRun(CodingStructure &cs, Partitioner& partitioner, uint32_t uiStartPos, uint32_t uiTotal, uint32_t &uiRun, ComponentID compBegin) +bool IntraPrediction::calCopyRun(CodingStructure &cs, Partitioner& partitioner, uint32_t startPos, uint32_t total, uint32_t &run, ComponentID compBegin) { - CodingUnit &cu = *cs.getCU(partitioner.chType); + CodingUnit &cu = *cs.getCU(partitioner.chType); TransformUnit &tu = *cs.getTU(partitioner.chType); - PelBuf curPLTIdx = tu.getcurPLTIdx(compBegin); - PLTtypeBuf runType = tu.getrunType(compBegin); + PelBuf curPLTIdx = tu.getcurPLTIdx(compBegin); + PLTtypeBuf runType = tu.getrunType(compBegin); - uint32_t uiIdx = uiStartPos; - uint32_t uiX; - uint32_t uiY; + uint32_t idx = startPos; + uint32_t xPos; + uint32_t yPos; bool valid = false; - uiRun = 0; - while (uiIdx < uiTotal) + run = 0; + while (idx < total) { - uiX = m_puiScanOrder[uiIdx].x; - uiY = m_puiScanOrder[uiIdx].y; - runType.at(uiX, uiY) = PLT_RUN_COPY; + xPos = m_puiScanOrder[idx].x; + yPos = m_puiScanOrder[idx].y; + runType.at(xPos, yPos) = PLT_RUN_COPY; - if (uiY == 0 && !cu.useRotation[compBegin]) + if (yPos == 0 && !cu.useRotation[compBegin]) { return false; } - if (uiX == 0 && cu.useRotation[compBegin]) + if (xPos == 0 && cu.useRotation[compBegin]) { return false; } - if (!cu.useRotation[compBegin] && curPLTIdx.at(uiX, uiY) == curPLTIdx.at(uiX, uiY - 1)) + if (!cu.useRotation[compBegin] && curPLTIdx.at(xPos, yPos) == curPLTIdx.at(xPos, yPos - 1)) { - uiRun++; + run++; valid = true; } - else if (cu.useRotation[compBegin] && curPLTIdx.at(uiX, uiY) == curPLTIdx.at(uiX - 1, uiY)) + else if (cu.useRotation[compBegin] && curPLTIdx.at(xPos, yPos) == curPLTIdx.at(xPos - 1, yPos)) { - uiRun++; + run++; valid = true; } else { break; } - uiIdx++; + idx++; } return valid; } -bool IntraPrediction::calIndexRun(CodingStructure &cs, Partitioner& partitioner, uint32_t uiStartPos, uint32_t uiTotal, uint32_t &uiRun, ComponentID compBegin) +bool IntraPrediction::calIndexRun(CodingStructure &cs, Partitioner& partitioner, uint32_t startPos, uint32_t total, uint32_t &run, ComponentID compBegin) { TransformUnit &tu = *cs.getTU(partitioner.chType); - PelBuf curPLTIdx = tu.getcurPLTIdx(compBegin); - PLTtypeBuf runType = tu.getrunType(compBegin); + PelBuf curPLTIdx = tu.getcurPLTIdx(compBegin); + PLTtypeBuf runType = tu.getrunType(compBegin); - uiRun = 1; - uint32_t uiIdx = uiStartPos; - while (uiIdx < uiTotal) + run = 1; + uint32_t idx = startPos; + while (idx < total) { - uint32_t uiX = m_puiScanOrder[uiIdx].x; - uint32_t uiY = m_puiScanOrder[uiIdx].y; - runType.at(uiX, uiY) = PLT_RUN_INDEX; + uint32_t xPos = m_puiScanOrder[idx].x; + uint32_t yPos = m_puiScanOrder[idx].y; + runType.at(xPos, yPos) = 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)) + uint32_t xPrev = idx == 0 ? 0 : m_puiScanOrder[idx - 1].x; + uint32_t yPrev = idx == 0 ? 0 : m_puiScanOrder[idx - 1].y; + if (idx > startPos && curPLTIdx.at(xPos, yPos) == curPLTIdx.at(xPrev, yPrev)) { - uiRun++; + run++; } - else if (uiIdx > uiStartPos) + else if (idx > startPos) { break; } - uiIdx++; + idx++; } return true; } @@ -2014,7 +2014,7 @@ void IntraPrediction::reorderPLT(CodingStructure& cs, Partitioner& partitioner, CodingUnit &cu = *cs.getCU(partitioner.chType); uint32_t reusePLTSizetmp = 0; - uint32_t PLTSizetmp = 0; + uint32_t pltSizetmp = 0; Pel curPLTtmp[MAX_NUM_COMPONENT][MAXPLTSIZE]; bool curPLTpred[MAXPLTPREDSIZE]; @@ -2056,7 +2056,7 @@ void IntraPrediction::reorderPLT(CodingStructure& cs, Partitioner& partitioner, curPLTtmp[comp][reusePLTSizetmp] = cs.prevPLT.curPLT[comp][predidx]; } reusePLTSizetmp++; - PLTSizetmp++; + pltSizetmp++; } } cu.reusePLTSize[compBegin] = reusePLTSizetmp; @@ -2066,12 +2066,12 @@ void IntraPrediction::reorderPLT(CodingStructure& cs, Partitioner& partitioner, { for (int comp = compBegin; comp < (compBegin + numComp); comp++) { - curPLTtmp[comp][PLTSizetmp] = cu.curPLT[comp][curidx]; + curPLTtmp[comp][pltSizetmp] = cu.curPLT[comp][curidx]; } - PLTSizetmp++; + pltSizetmp++; } } - assert(PLTSizetmp == cu.curPLTSize[compBegin]); + assert(pltSizetmp == cu.curPLTSize[compBegin]); for (int curidx = 0; curidx < cu.curPLTSize[compBegin]; curidx++) { for (int comp = compBegin; comp < (compBegin + numComp); comp++) diff --git a/source/Lib/CommonLib/IntraPrediction.h b/source/Lib/CommonLib/IntraPrediction.h index feb2bd7c071f7693c1dbd1af5de694ac81c3970d..d7e1978d7bb4e1cbda74fceab9cc3589d2457257 100644 --- a/source/Lib/CommonLib/IntraPrediction.h +++ b/source/Lib/CommonLib/IntraPrediction.h @@ -176,8 +176,8 @@ public: void geneIntrainterPred (const CodingUnit &cu); #if JVET_O0119_BASE_PALETTE_444 void reorderPLT(CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp); - bool calCopyRun(CodingStructure &cs, Partitioner& partitioner, uint32_t uiStartPos, uint32_t uiTotal, uint32_t &uiRun, ComponentID compBegin); - bool calIndexRun(CodingStructure &cs, Partitioner& partitioner, uint32_t uiStartPos, uint32_t uiTotal, uint32_t &uiRun, ComponentID compBegin); + bool calCopyRun(CodingStructure &cs, Partitioner& partitioner, uint32_t startPos, uint32_t total, uint32_t &run, ComponentID compBegin); + bool calIndexRun(CodingStructure &cs, Partitioner& partitioner, uint32_t startPos, uint32_t total, uint32_t &run, ComponentID compBegin); #endif }; diff --git a/source/Lib/CommonLib/Rom.cpp b/source/Lib/CommonLib/Rom.cpp index ac17188e2390b599721356a8e36933c1f88b598a..f6299e04c0095753b5724d69b39b005819f237b9 100644 --- a/source/Lib/CommonLib/Rom.cpp +++ b/source/Lib/CommonLib/Rom.cpp @@ -831,15 +831,15 @@ static void g_initMsbP1IdxLut() } } -uint8_t g_getMsbP1Idx(uint32_t uiVal) +uint8_t g_getMsbP1Idx(uint32_t val) { uint8_t idx = 0; - while (uiVal > 255) + while (val > 255) { - uiVal >>= 8; + val >>= 8; idx += 8; } - return idx + g_ucMsbP1Idx[uiVal]; + return idx + g_ucMsbP1Idx[val]; } #endif //! \} diff --git a/source/Lib/CommonLib/Rom.h b/source/Lib/CommonLib/Rom.h index a11618016ebc0347d7d136db2e9cbe63b078706c..d954a306f4386abad6aee5fcf33f4d0ccf861f5b 100644 --- a/source/Lib/CommonLib/Rom.h +++ b/source/Lib/CommonLib/Rom.h @@ -238,7 +238,7 @@ extern const uint8_t g_uhPLTQuant[52]; extern uint8_t g_ucRunTopLut[5]; extern uint8_t g_ucRunLeftLut[5]; extern uint8_t g_ucMsbP1Idx[256]; -extern uint8_t g_getMsbP1Idx(uint32_t uiVal); +extern uint8_t g_getMsbP1Idx(uint32_t val); #endif #endif //__TCOMROM__ diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index f7c36ded209126ecc06364137cd26225d01f16e0..2e7b6a714f0479edd460e05c65e9d84c0f8bac29 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -51,7 +51,6 @@ #include <cassert> #define JVET_O0119_BASE_PALETTE_444 1 // JVET-O0119: Palette mode in HEVC and palette mode signaling in JVET-N0258. Only enabled for YUV444. -#define FIXJC 1 #define JVET_O1136_TS_BDPCM_SIGNALLING 1 // JVET-O1136: Unified syntax for JVET-O0165/O0200/O0783 on TS and BDPCM signalling diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index 763a3483f02a03d3991d811ab39287d464529b63..bd9c23bc7cd074e80ee1b2cd878894acfd5e4913 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -1601,7 +1601,7 @@ bool CABACReader::end_of_ctu( CodingUnit& cu, CUCtx& cuCtx ) #if JVET_O0119_BASE_PALETTE_444 void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_t numComp, CUCtx& cuCtx) { - const SPS& sps = *(cu.cs->sps); + const SPS& sps = *(cu.cs->sps); TransformUnit& tu = *cu.firstTU; int curPLTidx = 0; @@ -1644,39 +1644,39 @@ void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_ cu.useEscape[compBegin] = true; // JC if (cu.curPLTSize[compBegin] > 0) { - uint32_t uiCode = 0; - uiCode = m_BinDecoder.decodeBinEP(); - cu.useEscape[compBegin] = (uiCode != 0); + uint32_t escCode = 0; + escCode = m_BinDecoder.decodeBinEP(); + cu.useEscape[compBegin] = (escCode != 0); } - uint32_t indexMaxSize = cu.useEscape[compBegin] ? (cu.curPLTSize[compBegin] + 1) : cu.curPLTSize[compBegin]; + uint32_t indexMaxSize = cu.useEscape[compBegin] ? (cu.curPLTSize[compBegin] + 1) : cu.curPLTSize[compBegin]; //encode index map - PLTtypeBuf runType = tu.getrunType(compBegin); - PelBuf runLength = tu.getrunLength(compBegin); - PelBuf curPLTIdx = tu.getcurPLTIdx(compBegin); - uint32_t uiHeight = cu.block(compBegin).height; - uint32_t uiWidth = cu.block(compBegin).width; - - int iNumCopyIndexRuns = -1; - bool lastRunType = 0; - uint32_t uiNumIndices = 0; - uint32_t uiAdjust = 0; - uint32_t symbol = 0; - std::list<int> lParsedIdxList; + PLTtypeBuf runType = tu.getrunType(compBegin); + PelBuf runLength = tu.getrunLength(compBegin); + PelBuf curPLTIdx = tu.getcurPLTIdx(compBegin); + uint32_t height = cu.block(compBegin).height; + uint32_t width = cu.block(compBegin).width; + + int numCopyIndexRuns = -1; + bool lastRunType = 0; + uint32_t numIndices = 0; + uint32_t adjust = 0; + uint32_t symbol = 0; + std::list<int> parsedIdxList; if (indexMaxSize > 1) { uint32_t currParam = 3 + ((indexMaxSize) >> 3); - uiNumIndices = m_BinDecoder.decodeRemAbsEP(currParam, false, MAX_NUM_CHANNEL_TYPE); // JC: number of indices (INDEX RUN) - uiNumIndices++; - iNumCopyIndexRuns = uiNumIndices; - while (uiNumIndices--) + numIndices = m_BinDecoder.decodeRemAbsEP(currParam, false, MAX_NUM_CHANNEL_TYPE); // JC: number of indices (INDEX RUN) + numIndices++; + numCopyIndexRuns = numIndices; + while (numIndices--) { - xReadTruncBinCode(symbol, indexMaxSize - uiAdjust); - uiAdjust = 1; - lParsedIdxList.push_back(symbol); + xReadTruncBinCode(symbol, indexMaxSize - adjust); + adjust = 1; + parsedIdxList.push_back(symbol); } lastRunType = m_BinDecoder.decodeBin(Ctx::RunTypeFlag()); parseScanRotationModeFlag(cu, compBegin); - uiAdjust = 0; + adjust = 0; } else { @@ -1706,9 +1706,9 @@ void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_ } - m_puiScanOrder = g_scanOrder[SCAN_UNGROUPED][(cu.useRotation[compBegin]) ? SCAN_TRAV_VER : SCAN_TRAV_HOR][gp_sizeIdxInfo->idxFrom(uiWidth)][gp_sizeIdxInfo->idxFrom(uiHeight)]; + m_puiScanOrder = g_scanOrder[SCAN_UNGROUPED][(cu.useRotation[compBegin]) ? SCAN_TRAV_VER : SCAN_TRAV_HOR][gp_sizeIdxInfo->idxFrom(width)][gp_sizeIdxInfo->idxFrom(height)]; uint32_t strPos = 0; - uint32_t endPos = uiHeight * uiWidth; + uint32_t endPos = height * width; while (strPos < endPos) { uint32_t posy = m_puiScanOrder[strPos].y; @@ -1728,13 +1728,13 @@ void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_ } else { - if (iNumCopyIndexRuns && strPos < endPos - 1) // JC: if uiNumIndices (decoder will know this value) == 0 - > only CopyAbove, if strPos == endPos - 1, the last RunType was already coded + if (numCopyIndexRuns && strPos < endPos - 1) // JC: if numIndices (decoder will know this value) == 0 - > only CopyAbove, if strPos == endPos - 1, the last RunType was already coded { runType.at(posx, posy) = (m_BinDecoder.decodeBin(Ctx::RunTypeFlag())); } else { - if (strPos == endPos - 1 && iNumCopyIndexRuns) + if (strPos == endPos - 1 && numCopyIndexRuns) { runType.at(posx, posy) = PLT_RUN_INDEX; } @@ -1750,29 +1750,29 @@ void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_ runType.at(posx, posy) = PLT_RUN_INDEX; } - Pel siCurLevel = 0; + Pel curLevel = 0; if (runType.at(posx, posy) == PLT_RUN_INDEX) { - if (!lParsedIdxList.empty()) + if (!parsedIdxList.empty()) { - siCurLevel = lParsedIdxList.front(); - lParsedIdxList.pop_front(); + curLevel = parsedIdxList.front(); + parsedIdxList.pop_front(); } else { - siCurLevel = 0; + curLevel = 0; } - xAdjustPLTIndex(cu, siCurLevel, strPos, curPLTIdx, runType, indexMaxSize, compBegin); + xAdjustPLTIndex(cu, curLevel, strPos, curPLTIdx, runType, indexMaxSize, compBegin); } if (indexMaxSize > 1) { - bool bLastRun; - iNumCopyIndexRuns -= (runType.at(posx, posy) == PLT_RUN_INDEX); - bLastRun = iNumCopyIndexRuns == 0 && runType.at(posx, posy) == lastRunType; - if (!bLastRun) + bool lastRun; + numCopyIndexRuns -= (runType.at(posx, posy) == PLT_RUN_INDEX); + lastRun = numCopyIndexRuns == 0 && runType.at(posx, posy) == lastRunType; + if (!lastRun) { - runLength.at(posx, posy) = cu_run_val((PLTRunMode)runType.at(posx, posy), siCurLevel, endPos - strPos - iNumCopyIndexRuns - 1 - lastRunType) + 1; + runLength.at(posx, posy) = cu_run_val((PLTRunMode)runType.at(posx, posy), curLevel, endPos - strPos - numCopyIndexRuns - 1 - lastRunType) + 1; } else { @@ -1788,31 +1788,31 @@ void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_ //assign run information for (int runidx = 1; runidx < runLength.at(posx, posy); runidx++) { - int PosYrun, PosXrun; - PosYrun = m_puiScanOrder[strPos + runidx].y; - PosXrun = m_puiScanOrder[strPos + runidx].x; - runType.at(PosXrun, PosYrun) = runType.at(posx, posy); - runLength.at(PosXrun, PosYrun) = runLength.at(posx, posy); + int posYrun, posXrun; + posYrun = m_puiScanOrder[strPos + runidx].y; + posXrun = m_puiScanOrder[strPos + runidx].x; + runType.at(posXrun, posYrun) = runType.at(posx, posy); + runLength.at(posXrun, posYrun) = runLength.at(posx, posy); } - uint32_t PosYrun; - uint32_t PosXrun; + uint32_t posYrun; + uint32_t posXrun; if (runType.at(posx, posy) == PLT_RUN_INDEX) { for (uint32_t idx = 1; idx < runLength.at(posx, posy); idx++) { - PosYrun = m_puiScanOrder[strPos + idx].y; - PosXrun = m_puiScanOrder[strPos + idx].x; - curPLTIdx.at(PosXrun, PosYrun) = curPLTIdx.at(posx, posy); + posYrun = m_puiScanOrder[strPos + idx].y; + posXrun = m_puiScanOrder[strPos + idx].x; + curPLTIdx.at(posXrun, posYrun) = curPLTIdx.at(posx, posy); } } else if (runType.at(posx, posy) == PLT_RUN_COPY) { for (uint32_t idx = 0; idx < runLength.at(posx, posy); idx++) { - PosYrun = m_puiScanOrder[strPos + idx].y; - PosXrun = m_puiScanOrder[strPos + idx].x; - curPLTIdx.at(PosXrun, PosYrun) = (cu.useRotation[compBegin]) ? curPLTIdx.at(PosXrun - 1, PosYrun) : curPLTIdx.at(PosXrun, PosYrun - 1); + posYrun = m_puiScanOrder[strPos + idx].y; + posXrun = m_puiScanOrder[strPos + idx].x; + curPLTIdx.at(posXrun, posYrun) = (cu.useRotation[compBegin]) ? curPLTIdx.at(posXrun - 1, posYrun) : curPLTIdx.at(posXrun, posYrun - 1); } } strPos += (runLength.at(posx, posy)); @@ -1854,39 +1854,39 @@ void CABACReader::parseScanRotationModeFlag(CodingUnit& cu, ComponentID compBegi { cu.useRotation[compBegin] = m_BinDecoder.decodeBin(Ctx::RotationFlag()); } -void CABACReader::xDecodePLTPredIndicator(CodingUnit& cu, uint32_t uiMaxPLTSize, ComponentID compBegin) +void CABACReader::xDecodePLTPredIndicator(CodingUnit& cu, uint32_t maxPLTSize, ComponentID compBegin) { - uint32_t uiSymbol, uiNumPLTPredicted = 0, idx = 0; + uint32_t symbol, numPltPredicted = 0, idx = 0; - uiSymbol = exp_golomb_eqprob(0); + symbol = exp_golomb_eqprob(0); - if (uiSymbol != 1) + if (symbol != 1) { - while (idx < cu.lastPLTSize[compBegin] && uiNumPLTPredicted < uiMaxPLTSize) + while (idx < cu.lastPLTSize[compBegin] && numPltPredicted < maxPLTSize) { if (idx > 0) { - uiSymbol = exp_golomb_eqprob(0); + symbol = exp_golomb_eqprob(0); } - if (uiSymbol == 1) + if (symbol == 1) { break; } - if (uiSymbol) + if (symbol) { - idx += uiSymbol - 1; + idx += symbol - 1; } cu.reuseflag[compBegin][idx] = 1; - uiNumPLTPredicted++; + numPltPredicted++; idx++; } } } -void CABACReader::xAdjustPLTIndex(CodingUnit& cu, Pel siCurLevel, uint32_t idx, PelBuf& paletteIdx, PLTtypeBuf& paletteRunType, int maxSymbol, ComponentID compBegin) +void CABACReader::xAdjustPLTIndex(CodingUnit& cu, Pel curLevel, uint32_t idx, PelBuf& paletteIdx, PLTtypeBuf& paletteRunType, int maxSymbol, ComponentID compBegin) { - uint32_t uiSymbol; - int iRefLevel = MAX_INT; + uint32_t symbol; + int refLevel = MAX_INT; uint32_t posy = m_puiScanOrder[idx].y; uint32_t posx = m_puiScanOrder[idx].x; if (idx) @@ -1895,10 +1895,10 @@ void CABACReader::xAdjustPLTIndex(CodingUnit& cu, Pel siCurLevel, uint32_t idx, uint32_t prevposx = m_puiScanOrder[idx - 1].x; if (paletteRunType.at(prevposx, prevposy) == PLT_RUN_INDEX) { - iRefLevel = paletteIdx.at(prevposx, prevposy); + refLevel = paletteIdx.at(prevposx, prevposy); if (paletteIdx.at(prevposx, prevposy) == cu.curPLTSize[compBegin]) // escape { - iRefLevel = maxSymbol - 1; + refLevel = maxSymbol - 1; } } else @@ -1906,97 +1906,97 @@ void CABACReader::xAdjustPLTIndex(CodingUnit& cu, Pel siCurLevel, uint32_t idx, if (cu.useRotation[compBegin]) { assert(prevposx > 0); - iRefLevel = paletteIdx.at(posx - 1, posy); + refLevel = paletteIdx.at(posx - 1, posy); if (paletteIdx.at(posx - 1, posy) == cu.curPLTSize[compBegin]) // escape mode { - iRefLevel = maxSymbol - 1; + refLevel = maxSymbol - 1; } } else { assert(prevposy > 0); - iRefLevel = paletteIdx.at(posx, posy - 1); + refLevel = paletteIdx.at(posx, posy - 1); if (paletteIdx.at(posx, posy - 1) == cu.curPLTSize[compBegin]) // escape mode { - iRefLevel = maxSymbol - 1; + refLevel = maxSymbol - 1; } } } maxSymbol--; } - uiSymbol = siCurLevel; - if (siCurLevel >= iRefLevel) // include escape mode + symbol = curLevel; + if (curLevel >= refLevel) // include escape mode { - uiSymbol++; + symbol++; } - paletteIdx.at(posx, posy) = uiSymbol; + paletteIdx.at(posx, posy) = symbol; } -uint32_t CABACReader::cu_run_val(PLTRunMode runtype, const uint32_t uiPltIdx, const uint32_t uiMaxRun) +uint32_t CABACReader::cu_run_val(PLTRunMode runtype, const uint32_t paletteIdx, const uint32_t maxRun) { - uint32_t ruiSymbol = 0; + uint32_t symbol = 0; if (runtype == PLT_RUN_COPY) { } else { - g_ucRunLeftLut[0] = (uiPltIdx < PLT_RUN_MSB_IDX_CTX_T1 ? 0 : (uiPltIdx < PLT_RUN_MSB_IDX_CTX_T2 ? 1 : 2)); + g_ucRunLeftLut[0] = (paletteIdx < PLT_RUN_MSB_IDX_CTX_T1 ? 0 : (paletteIdx < PLT_RUN_MSB_IDX_CTX_T2 ? 1 : 2)); } - ruiSymbol = xReadTruncMsbP1RefinementBits(runtype, uiMaxRun, PLT_RUN_MSB_IDX_CABAC_BYPASS_THRE); - return ruiSymbol; + symbol = xReadTruncMsbP1RefinementBits(runtype, maxRun, PLT_RUN_MSB_IDX_CABAC_BYPASS_THRE); + return symbol; } -uint32_t CABACReader::xReadTruncUnarySymbol(PLTRunMode runtype, uint32_t uiMax, uint32_t uiCtxT) +uint32_t CABACReader::xReadTruncUnarySymbol(PLTRunMode runtype, uint32_t maxVal, uint32_t ctxT) { - if (uiMax == 0) + if (maxVal == 0) return 0; - uint8_t *ucCtxLut; - ucCtxLut = (runtype == PLT_RUN_INDEX) ? g_ucRunLeftLut : g_ucRunTopLut; - uint32_t uiBin, uiIdx = 0; + uint8_t *ctxLut; + ctxLut = (runtype == PLT_RUN_INDEX) ? g_ucRunLeftLut : g_ucRunTopLut; + uint32_t bin, idx = 0; do { - if (uiIdx > uiCtxT) - uiBin = m_BinDecoder.decodeBinEP(); + if (idx > ctxT) + bin = m_BinDecoder.decodeBinEP(); else { - uiBin = m_BinDecoder.decodeBin( - (uiIdx <= uiCtxT) - ? ((runtype == PLT_RUN_INDEX) ? Ctx::IdxRunModel(ucCtxLut[uiIdx]) : Ctx::CopyRunModel(ucCtxLut[uiIdx])) - : ((runtype == PLT_RUN_INDEX) ? Ctx::IdxRunModel(ucCtxLut[uiCtxT]) : Ctx::CopyRunModel(ucCtxLut[uiCtxT]))); - // uiIdx <= uiCtxT? pcSCModel[ucCtxLut[uiIdx]] : pcSCModel[ucCtxLut[uiCtxT]] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); + bin = m_BinDecoder.decodeBin( + (idx <= ctxT) + ? ((runtype == PLT_RUN_INDEX) ? Ctx::IdxRunModel(ctxLut[idx]) : Ctx::CopyRunModel(ctxLut[idx])) + : ((runtype == PLT_RUN_INDEX) ? Ctx::IdxRunModel(ctxLut[ctxT]) : Ctx::CopyRunModel(ctxLut[ctxT]))); + // idx <= ctxT? pcSCModel[ctxLut[idx]] : pcSCModel[ctxLut[ctxT]] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); } - uiIdx++; - } while (uiBin && uiIdx < uiMax); + idx++; + } while (bin && idx < maxVal); - return (uiBin && uiIdx == uiMax) ? uiMax : uiIdx - 1; + return (bin && idx == maxVal) ? maxVal : idx - 1; } -uint32_t CABACReader::xReadTruncMsbP1RefinementBits(PLTRunMode runtype, uint32_t uiMax, uint32_t uiCtxT) +uint32_t CABACReader::xReadTruncMsbP1RefinementBits(PLTRunMode runtype, uint32_t maxVal, uint32_t ctxT) { - if (uiMax == 0) + if (maxVal == 0) { return 0; } - uint32_t uiSymbol; - uint32_t uiMsbP1 = xReadTruncUnarySymbol(runtype, g_getMsbP1Idx(uiMax), uiCtxT); - if (uiMsbP1 > 1) + uint32_t symbol; + uint32_t msbP1 = xReadTruncUnarySymbol(runtype, g_getMsbP1Idx(maxVal), ctxT); + if (msbP1 > 1) { - uint32_t uiNumBins = g_getMsbP1Idx(uiMax); - if (uiMsbP1 < uiNumBins) + uint32_t numBins = g_getMsbP1Idx(maxVal); + if (msbP1 < numBins) { - uint32_t uiBits = uiMsbP1 - 1; - uiSymbol = m_BinDecoder.decodeBinsEP(uiBits); - uiSymbol |= (1 << uiBits); + uint32_t bits = msbP1 - 1; + symbol = m_BinDecoder.decodeBinsEP(bits); + symbol |= (1 << bits); } else { - uint32_t curValue = 1 << (uiNumBins - 1); - xReadTruncBinCode(uiSymbol, uiMax + 1 - curValue); - uiSymbol += curValue; + uint32_t curValue = 1 << (numBins - 1); + xReadTruncBinCode(symbol, maxVal + 1 - curValue); + symbol += curValue; } } else - uiSymbol = uiMsbP1; + symbol = msbP1; - return uiSymbol; + return symbol; } #endif diff --git a/source/Lib/DecoderLib/CABACReader.h b/source/Lib/DecoderLib/CABACReader.h index 75297999921d819b2842c0db1bb99c9ba0ca8083..4cd8e6ba8f17bbf5f1930b92dc90f5524d3117d2 100644 --- a/source/Lib/DecoderLib/CABACReader.h +++ b/source/Lib/DecoderLib/CABACReader.h @@ -176,11 +176,11 @@ private: void xReadTruncBinCode(uint32_t& symbol, uint32_t maxSymbol); #if JVET_O0119_BASE_PALETTE_444 void parseScanRotationModeFlag ( CodingUnit& cu, ComponentID compBegin); - void xDecodePLTPredIndicator ( CodingUnit& cu, uint32_t uiMaxPLTSize, ComponentID compBegin); - void xAdjustPLTIndex ( CodingUnit& cu, Pel siCurLevel, uint32_t idx, PelBuf& paletteIdx, PLTtypeBuf& paletteRunType, int maxSymbol, ComponentID compBegin); - uint32_t cu_run_val ( PLTRunMode runtype, const uint32_t uiPltIdx, const uint32_t uiMaxRun); - uint32_t xReadTruncUnarySymbol ( PLTRunMode runtype, uint32_t uiMax, uint32_t uiCtxT); - uint32_t xReadTruncMsbP1RefinementBits( PLTRunMode runtype, uint32_t uiMax, uint32_t uiCtxT); + void xDecodePLTPredIndicator ( CodingUnit& cu, uint32_t maxPLTSize, ComponentID compBegin); + void xAdjustPLTIndex ( CodingUnit& cu, Pel curLevel, uint32_t idx, PelBuf& paletteIdx, PLTtypeBuf& paletteRunType, int maxSymbol, ComponentID compBegin); + uint32_t cu_run_val ( PLTRunMode runtype, const uint32_t pltIdx, const uint32_t maxRun); + uint32_t xReadTruncUnarySymbol ( PLTRunMode runtype, uint32_t maxVal, uint32_t ctxT); + uint32_t xReadTruncMsbP1RefinementBits( PLTRunMode runtype, uint32_t maxVal, uint32_t ctxT); #endif public: int shareStateDec; diff --git a/source/Lib/DecoderLib/DecCu.cpp b/source/Lib/DecoderLib/DecCu.cpp index b87676c143454f6fd3239b539529e42f1351289f..2751459985d7e87b64d6b8bb4b751433c92f2292 100644 --- a/source/Lib/DecoderLib/DecCu.cpp +++ b/source/Lib/DecoderLib/DecCu.cpp @@ -402,67 +402,67 @@ void DecCu::xReconIntraQT( CodingUnit &cu ) #if JVET_O0119_BASE_PALETTE_444 void DecCu::xReconPLT(CodingUnit &cu, ComponentID compBegin, uint32_t numComp) { - const SPS& sps = *(cu.cs->sps); + const SPS& sps = *(cu.cs->sps); TransformUnit& tu = *cu.firstTU; PelBuf curPLTIdx = tu.getcurPLTIdx(compBegin); - uint32_t uiHeight = cu.block(compBegin).height; - uint32_t uiWidth = cu.block(compBegin).width; + uint32_t height = cu.block(compBegin).height; + uint32_t width = cu.block(compBegin).width; //recon. pixels uint32_t scaleX = getComponentScaleX(COMPONENT_Cb, sps.getChromaFormatIdc()); uint32_t scaleY = getComponentScaleY(COMPONENT_Cb, sps.getChromaFormatIdc()); - for (uint32_t uiY = 0; uiY < uiHeight; uiY++) + for (uint32_t y = 0; y < height; y++) { - for (uint32_t uiX = 0; uiX < uiWidth; uiX++) + for (uint32_t x = 0; x < width; x++) { for (uint32_t compID = compBegin; compID < (compBegin + numComp); compID++) { const int channelBitDepth = cu.cs->sps->getBitDepth(toChannelType((ComponentID)compID)); const CompArea &area = cu.blocks[compID]; - PelBuf piPicReco = cu.cs->getRecoBuf(area); - PLTescapeBuf escapeValue = tu.getescapeValue((ComponentID)compID); - if (curPLTIdx.at(uiX, uiY) == cu.curPLTSize[compBegin]) + PelBuf picReco = cu.cs->getRecoBuf(area); + PLTescapeBuf escapeValue = tu.getescapeValue((ComponentID)compID); + if (curPLTIdx.at(x, y) == cu.curPLTSize[compBegin]) { - Pel iValue; + Pel value; QpParam cQP(tu, (ComponentID)compID); - int iQP = cQP.Qp; - int iQPrem = iQP % 6; - int iQPper = iQP / 6; + int qp = cQP.Qp; + int qpRem = qp % 6; + int qpPer = qp / 6; if (compBegin != COMPONENT_Y || compID == COMPONENT_Y) { - int InvquantiserRightShift = IQUANT_SHIFT; - int iAdd = 1 << (InvquantiserRightShift - 1); - iValue = ((((escapeValue.at(uiX, uiY)*g_invQuantScales[0][iQPrem]) << iQPper) + iAdd) >> InvquantiserRightShift); - iValue = Pel(ClipBD<int>(iValue, channelBitDepth)); - piPicReco.at(uiX, uiY) = iValue; + int invquantiserRightShift = IQUANT_SHIFT; + int add = 1 << (invquantiserRightShift - 1); + value = ((((escapeValue.at(x, y)*g_invQuantScales[0][qpRem]) << qpPer) + add) >> invquantiserRightShift); + value = Pel(ClipBD<int>(value, channelBitDepth)); + picReco.at(x, y) = value; } - else if (compBegin == COMPONENT_Y && compID != COMPONENT_Y && uiY % (1 << scaleY) == 0 && uiX % (1 << scaleX) == 0) + else if (compBegin == COMPONENT_Y && compID != COMPONENT_Y && y % (1 << scaleY) == 0 && x % (1 << scaleX) == 0) { - uint32_t PosYC = uiY >> scaleY; - uint32_t PosXC = uiX >> scaleX; - int InvquantiserRightShift = IQUANT_SHIFT; - int iAdd = 1 << (InvquantiserRightShift - 1); - iValue = ((((escapeValue.at(PosXC, PosYC)*g_invQuantScales[0][iQPrem]) << iQPper) + iAdd) >> InvquantiserRightShift); - iValue = Pel(ClipBD<int>(iValue, channelBitDepth)); - piPicReco.at(PosXC, PosYC) = iValue; + uint32_t posYC = y >> scaleY; + uint32_t posXC = x >> scaleX; + int invquantiserRightShift = IQUANT_SHIFT; + int add = 1 << (invquantiserRightShift - 1); + value = ((((escapeValue.at(posXC, posYC)*g_invQuantScales[0][qpRem]) << qpPer) + add) >> invquantiserRightShift); + value = Pel(ClipBD<int>(value, channelBitDepth)); + picReco.at(posXC, posYC) = value; } } else { - uint32_t curIdx = curPLTIdx.at(uiX, uiY); + uint32_t curIdx = curPLTIdx.at(x, y); if (compBegin != COMPONENT_Y || compID == COMPONENT_Y) { - piPicReco.at(uiX, uiY) = cu.curPLT[compID][curIdx]; + picReco.at(x, y) = cu.curPLT[compID][curIdx]; } - else if (compBegin == COMPONENT_Y && compID != COMPONENT_Y && uiY % (1 << scaleY) == 0 && uiX % (1 << scaleX) == 0) + else if (compBegin == COMPONENT_Y && compID != COMPONENT_Y && y % (1 << scaleY) == 0 && x % (1 << scaleX) == 0) { - uint32_t PosYC = uiY >> scaleY; - uint32_t PosXC = uiX >> scaleX; - piPicReco.at(PosXC, PosYC) = cu.curPLT[compID][curIdx]; + uint32_t posYC = y >> scaleY; + uint32_t posXC = x >> scaleX; + picReco.at(posXC, posYC) = cu.curPLT[compID][curIdx]; } } } @@ -471,8 +471,8 @@ void DecCu::xReconPLT(CodingUnit &cu, ComponentID compBegin, uint32_t numComp) for (uint32_t compID = compBegin; compID < (compBegin + numComp); compID++) { const CompArea &area = cu.blocks[compID]; - PelBuf piPicReco = cu.cs->getRecoBuf(area); - cu.cs->picture->getRecoBuf(area).copyFrom(piPicReco); + PelBuf picReco = cu.cs->getRecoBuf(area); + cu.cs->picture->getRecoBuf(area).copyFrom(picReco); cu.cs->setDecomp(area); } } diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index c7fc14c06308532c57bffe2873343216337599fc..0aff88208aae6379a187ff66cc64436247c22767 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -1456,12 +1456,10 @@ void CABACWriter::end_of_ctu( const CodingUnit& cu, CUCtx& cuCtx ) #if JVET_O0119_BASE_PALETTE_444 void CABACWriter::cu_palette_info(const CodingUnit& cu, ComponentID compBegin, uint32_t numComp, CUCtx& cuCtx) { - const SPS& sps = *(cu.cs->sps); + const SPS& sps = *(cu.cs->sps); TransformUnit& tu = *cu.firstTU; - uint32_t indexMaxSize = cu.useEscape[compBegin] ? (cu.curPLTSize[compBegin] + 1) : cu.curPLTSize[compBegin]; - if (cu.lastPLTSize[compBegin]) { xEncodePLTPredIndicator(cu, MAXPLTSIZE, compBegin); @@ -1494,22 +1492,20 @@ void CABACWriter::cu_palette_info(const CodingUnit& cu, ComponentID compBegin, u m_BinEncoder.encodeBinEP(signalEscape); } //encode index map - PLTtypeBuf runType = tu.getrunType(compBegin); - PelBuf runLength = tu.getrunLength(compBegin); - PelBuf curPLTIdx = tu.getcurPLTIdx(compBegin); - uint32_t uiHeight = cu.block(compBegin).height; - uint32_t uiWidth = cu.block(compBegin).width; - - m_puiScanOrder = g_scanOrder[SCAN_UNGROUPED][(cu.useRotation[compBegin]) ? SCAN_TRAV_VER : SCAN_TRAV_HOR][gp_sizeIdxInfo->idxFrom(uiWidth)][gp_sizeIdxInfo->idxFrom(uiHeight)]; - - uint32_t total = uiHeight * uiWidth; - - int iLastRunPos = -1; + PLTtypeBuf runType = tu.getrunType(compBegin); + PelBuf runLength = tu.getrunLength(compBegin); + PelBuf curPLTIdx = tu.getcurPLTIdx(compBegin); + uint32_t height = cu.block(compBegin).height; + uint32_t width = cu.block(compBegin).width; + + m_puiScanOrder = g_scanOrder[SCAN_UNGROUPED][(cu.useRotation[compBegin]) ? SCAN_TRAV_VER : SCAN_TRAV_HOR][gp_sizeIdxInfo->idxFrom(width)][gp_sizeIdxInfo->idxFrom(height)]; + uint32_t total = height * width; + int lastRunPos = -1; uint32_t lastRunType = 0; - uint32_t uiNumIndices = 0; - std::vector<int> vIdxPos, vParsedIdx; - vIdxPos.reserve(total); - vParsedIdx.reserve(total); + uint32_t numIndices = 0; + std::vector<int> idxPos, parsedIdx; + idxPos.reserve(total); + parsedIdx.reserve(total); if (indexMaxSize > 1) { int idx = 0, run = 0; @@ -1519,24 +1515,24 @@ void CABACWriter::cu_palette_info(const CodingUnit& cu, ComponentID compBegin, u uint32_t posx = m_puiScanOrder[idx].x; if (runType.at(posx, posy) == PLT_RUN_INDEX) { - vIdxPos.push_back(idx); - uiNumIndices++; + idxPos.push_back(idx); + numIndices++; } lastRunType = runType.at(posx, posy); - iLastRunPos = idx; + lastRunPos = idx; run = runLength.at(posx, posy); idx += run; } uint32_t currParam = 3 + ((indexMaxSize) >> 3); - uint32_t uiMappedValue; - assert(uiNumIndices); - assert(uiNumIndices > 0); - uiMappedValue = uiNumIndices - 1; - m_BinEncoder.encodeRemAbsEP(uiMappedValue, currParam, false, MAX_NUM_CHANNEL_TYPE); // JC: code number of indices (PLT_RUN_INDEX) - auto vIdxPosEnd = vIdxPos.end(); - for (auto iter = vIdxPos.begin(); iter != vIdxPosEnd; ++iter) + uint32_t mappedValue; + assert(numIndices); + assert(numIndices > 0); + mappedValue = numIndices - 1; + m_BinEncoder.encodeRemAbsEP(mappedValue, currParam, false, MAX_NUM_CHANNEL_TYPE); // JC: code number of indices (PLT_RUN_INDEX) + auto idxPosEnd = idxPos.end(); + for (auto iter = idxPos.begin(); iter != idxPosEnd; ++iter) { - vParsedIdx.push_back( writePLTIndex(cu, *iter, curPLTIdx, runType, indexMaxSize, compBegin)); + parsedIdx.push_back( writePLTIndex(cu, *iter, curPLTIdx, runType, indexMaxSize, compBegin)); } m_BinEncoder.encodeBin(lastRunType, Ctx::RunTypeFlag()); codeScanRotationModeFlag(cu, compBegin); @@ -1569,9 +1565,9 @@ void CABACWriter::cu_palette_info(const CodingUnit& cu, ComponentID compBegin, u } uint32_t strPos = 0; - uint32_t endPos = uiHeight * uiWidth; - auto vParsedIdxEnd = vParsedIdx.end(); - auto vParsedIdxIter = vParsedIdx.begin(); + uint32_t endPos = height * width; + auto parsedIdxEnd = parsedIdx.end(); + auto parsedIdxIter = parsedIdx.begin(); while (strPos < endPos) { uint32_t posy = m_puiScanOrder[strPos].y; @@ -1592,32 +1588,32 @@ void CABACWriter::cu_palette_info(const CodingUnit& cu, ComponentID compBegin, u } else { - if (uiNumIndices && strPos < endPos - 1) // if uiNumIndices (decoder will know this value) == 0 - > only CopyAbove, if strPos == endPos - 1, the last RunType was already coded + if (numIndices && strPos < endPos - 1) // if numIndices (decoder will know this value) == 0 - > only CopyAbove, if strPos == endPos - 1, the last RunType was already coded { m_BinEncoder.encodeBin((runType.at(posx, posy)), Ctx::RunTypeFlag()); } } } - Pel siCurLevel = 0; + Pel curLevel = 0; if (runType.at(posx, posy) == PLT_RUN_INDEX) { - if (vParsedIdxIter != vParsedIdxEnd) + if (parsedIdxIter != parsedIdxEnd) { - siCurLevel = *vParsedIdxIter++; + curLevel = *parsedIdxIter++; } else { - siCurLevel = 0; + curLevel = 0; } } if (indexMaxSize > 1) { - if (iLastRunPos != strPos) + if (lastRunPos != strPos) { - uiNumIndices -= (runType.at(posx, posy) == PLT_RUN_INDEX); - cu_run_val(runLength.at(posx, posy) - 1, (PLTRunMode)runType.at(posx, posy), siCurLevel, endPos - strPos - uiNumIndices - 1 - lastRunType); + numIndices -= (runType.at(posx, posy) == PLT_RUN_INDEX); + cu_run_val(runLength.at(posx, posy) - 1, (PLTRunMode)runType.at(posx, posy), curLevel, endPos - strPos - numIndices - 1 - lastRunType); } } @@ -1659,16 +1655,16 @@ void CABACWriter::codeScanRotationModeFlag(const CodingUnit& cu, ComponentID com { m_BinEncoder.encodeBin((cu.useRotation[compBegin]), Ctx::RotationFlag()); } -void CABACWriter::xEncodePLTPredIndicator(const CodingUnit& cu, uint32_t uiMaxPLTSize, ComponentID compBegin) +void CABACWriter::xEncodePLTPredIndicator(const CodingUnit& cu, uint32_t maxPLTSize, ComponentID compBegin) { int lastPredIdx = -1; uint32_t run = 0; - uint32_t uiNumPLTPredicted = 0; + uint32_t numPLTPredicted = 0; for (uint32_t idx = 0; idx < cu.lastPLTSize[compBegin]; idx++) { if (cu.reuseflag[compBegin][idx]) { - uiNumPLTPredicted++; + numPLTPredicted++; lastPredIdx = idx; } } @@ -1687,7 +1683,7 @@ void CABACWriter::xEncodePLTPredIndicator(const CodingUnit& cu, uint32_t uiMaxPL } idx++; } - if ((uiNumPLTPredicted < uiMaxPLTSize && lastPredIdx + 1 < cu.lastPLTSize[compBegin]) || !uiNumPLTPredicted) + if ((numPLTPredicted < maxPLTSize && lastPredIdx + 1 < cu.lastPLTSize[compBegin]) || !numPLTPredicted) { exp_golomb_eqprob(1, 0); } @@ -1696,61 +1692,61 @@ Pel CABACWriter::writePLTIndex(const CodingUnit& cu, uint32_t idx, PelBuf& palet { uint32_t posy = m_puiScanOrder[idx].y; uint32_t posx = m_puiScanOrder[idx].x; - Pel siCurLevel = (paletteIdx.at(posx, posy) == cu.curPLTSize[compBegin]) ? (maxSymbol - 1) : paletteIdx.at(posx, posy); + Pel curLevel = (paletteIdx.at(posx, posy) == cu.curPLTSize[compBegin]) ? (maxSymbol - 1) : paletteIdx.at(posx, posy); if (idx) // R0348: remove index redundancy { uint32_t prevposy = m_puiScanOrder[idx - 1].y; uint32_t prevposx = m_puiScanOrder[idx - 1].x; if (paletteRunType.at(prevposx, prevposy) == PLT_RUN_INDEX) { - Pel siLeftLevel = paletteIdx.at(prevposx, prevposy); // left index - if (siLeftLevel == cu.curPLTSize[compBegin]) // escape mode + Pel leftLevel = paletteIdx.at(prevposx, prevposy); // left index + if (leftLevel == cu.curPLTSize[compBegin]) // escape mode { - siLeftLevel = maxSymbol - 1; + leftLevel = maxSymbol - 1; } - assert(siLeftLevel != siCurLevel); - if (siCurLevel > siLeftLevel) + assert(leftLevel != curLevel); + if (curLevel > leftLevel) { - siCurLevel--; + curLevel--; } } else { - Pel siAboveLevel; + Pel aboveLevel; if (cu.useRotation[compBegin]) { assert(prevposx > 0); - siAboveLevel = paletteIdx.at(posx - 1, posy); + aboveLevel = paletteIdx.at(posx - 1, posy); if (paletteIdx.at(posx - 1, posy) == cu.curPLTSize[compBegin]) // escape mode { - siAboveLevel = maxSymbol - 1; + aboveLevel = maxSymbol - 1; } } else { assert(prevposy > 0); - siAboveLevel = paletteIdx.at(posx, posy - 1); + aboveLevel = paletteIdx.at(posx, posy - 1); if (paletteIdx.at(posx, posy - 1) == cu.curPLTSize[compBegin]) // escape mode { - siAboveLevel = maxSymbol - 1; + aboveLevel = maxSymbol - 1; } } - assert(siCurLevel != siAboveLevel); - if (siCurLevel > siAboveLevel) + assert(curLevel != aboveLevel); + if (curLevel > aboveLevel) { - siCurLevel--; + curLevel--; } } maxSymbol--; } assert(maxSymbol > 0); - assert(siCurLevel >= 0); - assert(maxSymbol > siCurLevel); + assert(curLevel >= 0); + assert(maxSymbol > curLevel); if (maxSymbol > 1) { - xWriteTruncBinCode(siCurLevel, maxSymbol); + xWriteTruncBinCode(curLevel, maxSymbol); } - return siCurLevel; + return curLevel; } void CABACWriter::encodeRunType(const CodingUnit& cu, PLTtypeBuf& runType, uint32_t idx, ScanElement *refScanOrder, ComponentID compBegin) @@ -1778,74 +1774,74 @@ void CABACWriter::encodeRunType(const CodingUnit& cu, PLTtypeBuf& runType, uint } } -void CABACWriter::cu_run_val(uint32_t uiRun, PLTRunMode runtype, const uint32_t uiPltIdx, const uint32_t uiMaxRun) +void CABACWriter::cu_run_val(uint32_t run, PLTRunMode runtype, const uint32_t paletteIdx, const uint32_t maxRun) { if (runtype == PLT_RUN_COPY) { } else { - g_ucRunLeftLut[0] = (uiPltIdx < PLT_RUN_MSB_IDX_CTX_T1 ? 0 : (uiPltIdx < PLT_RUN_MSB_IDX_CTX_T2 ? 1 : 2)); + g_ucRunLeftLut[0] = (paletteIdx < PLT_RUN_MSB_IDX_CTX_T1 ? 0 : (paletteIdx < PLT_RUN_MSB_IDX_CTX_T2 ? 1 : 2)); } - xWriteTruncMsbP1RefinementBits(uiRun, runtype, uiMaxRun, PLT_RUN_MSB_IDX_CABAC_BYPASS_THRE); + xWriteTruncMsbP1RefinementBits(run, runtype, maxRun, PLT_RUN_MSB_IDX_CABAC_BYPASS_THRE); } -uint32_t CABACWriter::xWriteTruncMsbP1(uint32_t uiSymbol, PLTRunMode runtype, uint32_t uiMax, uint32_t uiCtxT) +uint32_t CABACWriter::xWriteTruncMsbP1(uint32_t symbol, PLTRunMode runtype, uint32_t uiMax, uint32_t uiCtxT) { if (uiMax == 0) return 0; - uint8_t *ucCtxLut; - ucCtxLut = (runtype == PLT_RUN_INDEX) ? g_ucRunLeftLut : g_ucRunTopLut; + uint8_t *ctxLut; + ctxLut = (runtype == PLT_RUN_INDEX) ? g_ucRunLeftLut : g_ucRunTopLut; - uint32_t uiMsbP1; - for (uiMsbP1 = 0; uiSymbol > 0; uiMsbP1++) + uint32_t msbP1; + for (msbP1 = 0; symbol > 0; msbP1++) { - uiSymbol >>= 1; - if (uiMsbP1 > uiCtxT) + symbol >>= 1; + if (msbP1 > uiCtxT) { m_BinEncoder.encodeBinEP(1); } else - m_BinEncoder.encodeBin(1, (uiMsbP1 <= uiCtxT) - ? ((runtype == PLT_RUN_INDEX) ? Ctx::IdxRunModel(ucCtxLut[uiMsbP1]) : Ctx::CopyRunModel(ucCtxLut[uiMsbP1])) - : ((runtype == PLT_RUN_INDEX) ? Ctx::IdxRunModel(ucCtxLut[uiCtxT]) : Ctx::CopyRunModel(ucCtxLut[uiCtxT]))); + m_BinEncoder.encodeBin(1, (msbP1 <= uiCtxT) + ? ((runtype == PLT_RUN_INDEX) ? Ctx::IdxRunModel(ctxLut[msbP1]) : Ctx::CopyRunModel(ctxLut[msbP1])) + : ((runtype == PLT_RUN_INDEX) ? Ctx::IdxRunModel(ctxLut[uiCtxT]) : Ctx::CopyRunModel(ctxLut[uiCtxT]))); } - assert(uiMsbP1 <= uiMax); - if (uiMsbP1 < uiMax) + assert(msbP1 <= uiMax); + if (msbP1 < uiMax) { - if (uiMsbP1 > uiCtxT) + if (msbP1 > uiCtxT) { m_BinEncoder.encodeBinEP(0); } else - m_BinEncoder.encodeBin(0, uiMsbP1 <= uiCtxT - ? ((runtype == PLT_RUN_INDEX) ? Ctx::IdxRunModel(ucCtxLut[uiMsbP1]) : Ctx::CopyRunModel(ucCtxLut[uiMsbP1])) - : ((runtype == PLT_RUN_INDEX) ? Ctx::IdxRunModel(ucCtxLut[uiCtxT]) : Ctx::CopyRunModel(ucCtxLut[uiCtxT]))); + m_BinEncoder.encodeBin(0, msbP1 <= uiCtxT + ? ((runtype == PLT_RUN_INDEX) ? Ctx::IdxRunModel(ctxLut[msbP1]) : Ctx::CopyRunModel(ctxLut[msbP1])) + : ((runtype == PLT_RUN_INDEX) ? Ctx::IdxRunModel(ctxLut[uiCtxT]) : Ctx::CopyRunModel(ctxLut[uiCtxT]))); - //m_pcBinIf->encodeBin(0, uiMsbP1 <= uiCtxT? pcSCModel[ucCtxLut[uiMsbP1]] : pcSCModel[ucCtxLut[uiCtxT]]); + //m_pcBinIf->encodeBin(0, msbP1 <= uiCtxT? pcSCModel[ctxLut[msbP1]] : pcSCModel[ctxLut[uiCtxT]]); } - return uiMsbP1; + return msbP1; } -void CABACWriter::xWriteTruncMsbP1RefinementBits(uint32_t uiSymbol, PLTRunMode runtype, uint32_t uiMax, uint32_t uiCtxT) +void CABACWriter::xWriteTruncMsbP1RefinementBits(uint32_t symbol, PLTRunMode runtype, uint32_t maxVal, uint32_t uiCtxT) { - if (uiMax == 0) + if (maxVal == 0) return; - uint32_t uiMsbP1 = xWriteTruncMsbP1(uiSymbol, runtype, g_getMsbP1Idx(uiMax), uiCtxT); - if (uiMsbP1 > 1) + uint32_t msbP1 = xWriteTruncMsbP1(symbol, runtype, g_getMsbP1Idx(maxVal), uiCtxT); + if (msbP1 > 1) { - uint32_t uiNumBins = g_getMsbP1Idx(uiMax); - if (uiMsbP1 < uiNumBins) + uint32_t numBins = g_getMsbP1Idx(maxVal); + if (msbP1 < numBins) { - uint32_t uiBits = uiMsbP1 - 1; - m_BinEncoder.encodeBinsEP(uiSymbol & ((1 << uiBits) - 1), uiBits); + uint32_t bits = msbP1 - 1; + m_BinEncoder.encodeBinsEP(symbol & ((1 << bits) - 1), bits); } else { - uint32_t curValue = 1 << (uiNumBins - 1); - xWriteTruncBinCode(uiSymbol - curValue, uiMax + 1 - curValue); + uint32_t curValue = 1 << (numBins - 1); + xWriteTruncBinCode(symbol - curValue, maxVal + 1 - curValue); } } } diff --git a/source/Lib/EncoderLib/CABACWriter.h b/source/Lib/EncoderLib/CABACWriter.h index f55d6a6162437694ca0edebbf09a2946da0c7dcf..617b33b8f192cbbe6e6df591dafb9c7ee5f59e77 100644 --- a/source/Lib/EncoderLib/CABACWriter.h +++ b/source/Lib/EncoderLib/CABACWriter.h @@ -111,7 +111,7 @@ public: void mip_pred_mode ( const PredictionUnit& pu ); #if JVET_O0119_BASE_PALETTE_444 void cu_palette_info ( const CodingUnit& cu, ComponentID compBegin, uint32_t numComp, CUCtx& cuCtx); - void cu_run_val ( uint32_t uiRun, PLTRunMode runtype, const uint32_t uiPltIdx, const uint32_t uiMaxRun); + void cu_run_val ( uint32_t run, PLTRunMode runtype, const uint32_t paletteIdx, const uint32_t maxRun); void encodeRunType ( const CodingUnit& cu, PLTtypeBuf& runType, uint32_t idx, ScanElement *refScanOrder, ComponentID compBegin); Pel writePLTIndex ( const CodingUnit& cu, uint32_t idx, PelBuf& paletteIdx, PLTtypeBuf& paletteRunType, int maxSymbol, ComponentID compBegin); #endif @@ -194,9 +194,9 @@ private: void xWriteTruncBinCode(uint32_t uiSymbol, uint32_t uiMaxSymbol); #if JVET_O0119_BASE_PALETTE_444 void codeScanRotationModeFlag ( const CodingUnit& cu, ComponentID compBegin); - void xEncodePLTPredIndicator ( const CodingUnit& cu, uint32_t uiMaxPLTSize, ComponentID compBegin); - uint32_t xWriteTruncMsbP1 ( uint32_t uiSymbol, PLTRunMode runtype, uint32_t uiMax, uint32_t uiCtxT); - void xWriteTruncMsbP1RefinementBits ( uint32_t uiSymbol, PLTRunMode runtype, uint32_t uiMax, uint32_t uiCtxT); + void xEncodePLTPredIndicator ( const CodingUnit& cu, uint32_t maxPltSize, ComponentID compBegin); + uint32_t xWriteTruncMsbP1 ( uint32_t symbol, PLTRunMode runtype, uint32_t maxVal, uint32_t ctxT); + void xWriteTruncMsbP1RefinementBits ( uint32_t symbol, PLTRunMode runtype, uint32_t maxVal, uint32_t ctxT); #endif private: BinEncIf& m_BinEncoder; diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index a9de21935450ded2412b198d6fedb1f9685054b4..ddfd954d2e11aca6d44b6a65ef8188911e3bb96a 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -1894,8 +1894,8 @@ void EncCu::xCheckPLT(CodingStructure *&tempCS, CodingStructure *&bestCS, Partit xCalDebCost(*tempCS, partitioner); tempCS->useDbCost = m_pcEncCfg->getUseEncDbOpt(); - const Area curr_cu_area = cu.block(getFirstComponentOfChannel(partitioner.chType)); - cu.slice->m_mapPltCost[curr_cu_area.pos()][curr_cu_area.size()] = tempCS->cost; + const Area currCuArea = cu.block(getFirstComponentOfChannel(partitioner.chType)); + cu.slice->m_mapPltCost[currCuArea.pos()][currCuArea.size()] = tempCS->cost; #if WCG_EXT DTRACE_MODE_COST(*tempCS, m_pcRdCost->getLambda(true)); #else diff --git a/source/Lib/EncoderLib/EncSlice.cpp b/source/Lib/EncoderLib/EncSlice.cpp index 66792eab32fc925557869872af2a9e1be81edde3..ee9a44e9e00704ffdc38ec009f6cf5bc764758c6 100644 --- a/source/Lib/EncoderLib/EncSlice.cpp +++ b/source/Lib/EncoderLib/EncSlice.cpp @@ -1392,8 +1392,8 @@ void EncSlice::compressSlice( Picture* pcPic, const bool bCompressEntireSlice, c #endif // ENABLE_QPA #if JVET_O0119_BASE_PALETTE_444 - bool bCheckPLTRatio = m_pcCfg->getIntraPeriod() != 1 && pcSlice->isIRAP(); - if (bCheckPLTRatio) + bool checkPLTRatio = m_pcCfg->getIntraPeriod() != 1 && pcSlice->isIRAP(); + if (checkPLTRatio) { doPlt = true; } @@ -1434,7 +1434,7 @@ void EncSlice::compressSlice( Picture* pcPic, const bool bCompressEntireSlice, c #endif encodeCtus( pcPic, bCompressEntireSlice, bFastDeltaQP, startCtuTsAddr, boundingCtuTsAddr, m_pcLib ); #if JVET_O0119_BASE_PALETTE_444 - if (bCheckPLTRatio) + if (checkPLTRatio) { int totalArea = 0; int pltArea = 0; @@ -1442,13 +1442,13 @@ void EncSlice::compressSlice( Picture* pcPic, const bool bCompressEntireSlice, c { for (int i = 0; i < MAX_NUM_TBLOCKS; ++i) { - int pu_area = apu->blocks[i].width * apu->blocks[i].height; + int puArea = apu->blocks[i].width * apu->blocks[i].height; if (apu->blocks[i].width > 0 && apu->blocks[i].height > 0) { - totalArea += pu_area; + totalArea += puArea; if (CU::isPLT(*apu->cu) || CU::isIBC(*apu->cu)) { - pltArea += pu_area; + pltArea += puArea; } break; } diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp index 6a5d5248b6edd494ca88da52c4556ca7fcadcff1..309cbcb940b86237aa79306d6f09a4cbccc9e8eb 100644 --- a/source/Lib/EncoderLib/IntraSearch.cpp +++ b/source/Lib/EncoderLib/IntraSearch.cpp @@ -1464,10 +1464,10 @@ void IntraSearch::xEncPCM(CodingStructure &cs, Partitioner& partitioner, const C #if JVET_O0119_BASE_PALETTE_444 void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp) { - CodingUnit &cu = *cs.getCU(partitioner.chType); + CodingUnit &cu = *cs.getCU(partitioner.chType); TransformUnit &tu = *cs.getTU(partitioner.chType); - uint32_t uiHeight = cu.block(compBegin).height; - uint32_t uiWidth = cu.block(compBegin).width; + uint32_t height = cu.block(compBegin).height; + uint32_t width = cu.block(compBegin).width; m_orgCtxRD = PLTCtx(m_CABACEstimator->getCtx()); if (m_pcEncCfg->getReshaper() && (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag())) @@ -1476,8 +1476,8 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo cs.getPredBuf().Y().rspSignal(m_pcReshape->getFwdLUT()); } - Pel *pRunLength = tu.getRunLens (compBegin); - bool *pRunType = tu.getRunTypes(compBegin); + Pel *runLength = tu.getRunLens (compBegin); + bool *runType = tu.getRunTypes(compBegin); cu.lastPLTSize[compBegin] = cs.prevPLT.curPLTSize[compBegin]; //derive palette derivePLTLossy(cs, partitioner, compBegin, numComp); @@ -1486,22 +1486,22 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo //calculate palette index preCalcPLTIndex(cs, partitioner, compBegin, numComp); //derive run - uint64_t uiBits = MAX_UINT; - deriveRunAndCalcBits(cs, partitioner, compBegin, numComp, PLT_SCAN_HORTRAV, uiBits); + uint64_t bits = MAX_UINT; + deriveRunAndCalcBits(cs, partitioner, compBegin, numComp, PLT_SCAN_HORTRAV, bits); if ((cu.curPLTSize[compBegin] + cu.useEscape[compBegin]) > 1) { - deriveRunAndCalcBits(cs, partitioner, compBegin, numComp, PLT_SCAN_VERTRAV, uiBits); + deriveRunAndCalcBits(cs, partitioner, compBegin, numComp, PLT_SCAN_VERTRAV, bits); } cu.useRotation[compBegin] = m_bBestScanRotationMode; - memcpy(pRunType, m_runTypeRD, sizeof(bool)*uiWidth*uiHeight); - memcpy(pRunLength, m_runLengthRD, sizeof(Pel)*uiWidth*uiHeight); + memcpy(runType, m_runTypeRD, sizeof(bool)*width*height); + memcpy(runLength, m_runLengthRD, sizeof(Pel)*width*height); //reconstruct pixel PelBuf curPLTIdx = tu.getcurPLTIdx(compBegin); - for (uint32_t uiY = 0; uiY < uiHeight; uiY++) + for (uint32_t y = 0; y < height; y++) { - for (uint32_t uiX = 0; uiX < uiWidth; uiX++) + for (uint32_t x = 0; x < width; x++) { - if (curPLTIdx.at(uiX, uiY) == cu.curPLTSize[compBegin]) + if (curPLTIdx.at(x, y) == cu.curPLTSize[compBegin]) { } @@ -1509,19 +1509,17 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo { for (uint32_t compID = compBegin; compID < (compBegin + numComp); compID++) { - CompArea area = cu.blocks[compID]; - PelBuf recBuf = cs.getRecoBuf(area); + CompArea area = cu.blocks[compID]; + PelBuf recBuf = cs.getRecoBuf(area); uint32_t scaleX = getComponentScaleX((ComponentID)COMPONENT_Cb, cs.sps->getChromaFormatIdc()); uint32_t scaleY = getComponentScaleY((ComponentID)COMPONENT_Cb, cs.sps->getChromaFormatIdc()); if (compBegin != COMPONENT_Y || compID == COMPONENT_Y) { - recBuf.at(uiX, uiY) = cu.curPLT[compID][curPLTIdx.at(uiX, uiY)]; + recBuf.at(x, y) = cu.curPLT[compID][curPLTIdx.at(x, y)]; } - else if (compBegin == COMPONENT_Y && compID != COMPONENT_Y && uiY % (1 << scaleY) == 0 && uiX % (1 << scaleX) == 0) + else if (compBegin == COMPONENT_Y && compID != COMPONENT_Y && y % (1 << scaleY) == 0 && x % (1 << scaleX) == 0) { - CompArea area = cu.blocks[compID]; - PelBuf recBuf = cs.getRecoBuf(area); - recBuf.at(uiX >> scaleX, uiY >> scaleY) = cu.curPLT[compID][curPLTIdx.at(uiX, uiY)]; + recBuf.at(x >> scaleX, y >> scaleY) = cu.curPLT[compID][curPLTIdx.at(x, y)]; } } } @@ -1549,8 +1547,8 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo if (compID == COMPONENT_Y && !(m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled())) { const CompArea &areaY = cu.Y(); - CompArea tmpArea1(COMPONENT_Y, areaY.chromaFormat, Position(0, 0), areaY.size()); - PelBuf tmpRecLuma = m_tmpStorageLCU.getBuf(tmpArea1); + CompArea tmpArea1(COMPONENT_Y, areaY.chromaFormat, Position(0, 0), areaY.size()); + PelBuf tmpRecLuma = m_tmpStorageLCU.getBuf(tmpArea1); tmpRecLuma.copyFrom(reco); tmpRecLuma.rspSignal(m_pcReshape->getInvLUT()); distortion += m_pcRdCost->getDistPart(org, tmpRecLuma, cs.sps->getBitDepth(toChannelType(compID)), compID, DF_SSE_WTD, &orgLuma); @@ -1570,135 +1568,132 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo cs.setDecomp(area); cs.picture->getRecoBuf(area).copyFrom(cs.getRecoBuf(area)); } -void IntraSearch::deriveRunAndCalcBits(CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp, PLTScanMode pltScanMode, uint64_t& uiMinBits) +void IntraSearch::deriveRunAndCalcBits(CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp, PLTScanMode pltScanMode, uint64_t& minBits) { - CodingUnit &cu = *cs.getCU(partitioner.chType); + CodingUnit &cu = *cs.getCU(partitioner.chType); TransformUnit &tu = *cs.getTU(partitioner.chType); - uint32_t uiHeight = cu.block(compBegin).height; - uint32_t uiWidth = cu.block(compBegin).width; - Pel *pRunLength = tu.getRunLens (compBegin); - bool *pRunType = tu.getRunTypes(compBegin); + uint32_t height = cu.block(compBegin).height; + uint32_t width = cu.block(compBegin).width; + Pel *runLength = tu.getRunLens (compBegin); + bool *runType = tu.getRunTypes(compBegin); - cu.useRotation[compBegin] = (pltScanMode == PLT_SCAN_VERTRAV); // JC: rotate - - m_puiScanOrder = g_scanOrder[SCAN_UNGROUPED][(cu.useRotation[compBegin]) ? SCAN_TRAV_VER : SCAN_TRAV_HOR][gp_sizeIdxInfo->idxFrom(uiWidth)][gp_sizeIdxInfo->idxFrom(uiHeight)]; + cu.useRotation[compBegin] = (pltScanMode == PLT_SCAN_VERTRAV); + m_puiScanOrder = g_scanOrder[SCAN_UNGROUPED][(cu.useRotation[compBegin]) ? SCAN_TRAV_VER : SCAN_TRAV_HOR][gp_sizeIdxInfo->idxFrom(width)][gp_sizeIdxInfo->idxFrom(height)]; deriveRun(cs, partitioner, compBegin); m_CABACEstimator->getCtx() = PLTCtx(m_orgCtxRD); m_CABACEstimator->resetBits(); - CUCtx cuCtx; cuCtx.isDQPCoded = true; cuCtx.isChromaQpAdjCoded = true; m_CABACEstimator->cu_palette_info(cu, compBegin, numComp, cuCtx); - uint64_t nBitsTemp = m_CABACEstimator->getEstFracBits(); - if (uiMinBits > nBitsTemp) + uint64_t bitsTemp = m_CABACEstimator->getEstFracBits(); + if (minBits > bitsTemp) { m_bBestScanRotationMode = pltScanMode; - memcpy(m_runTypeRD, pRunType, sizeof(bool)*uiWidth*uiHeight); - memcpy(m_runLengthRD, pRunLength, sizeof(Pel)*uiWidth*uiHeight); - uiMinBits = nBitsTemp; + memcpy(m_runTypeRD, runType, sizeof(bool)*width*height); + memcpy(m_runLengthRD, runLength, sizeof(Pel)*width*height); + minBits = bitsTemp; } } void IntraSearch::deriveRun(CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin) { - CodingUnit &cu = *cs.getCU(partitioner.chType); + CodingUnit &cu = *cs.getCU(partitioner.chType); TransformUnit &tu = *cs.getTU(partitioner.chType); - uint32_t uiHeight = cu.block(compBegin).height; - uint32_t uiWidth = cu.block(compBegin).width; - uint32_t uiTotal = uiHeight * uiWidth, uiIdx = 0; - uint32_t uiStartPos = 0; + uint32_t height = cu.block(compBegin).height; + uint32_t width = cu.block(compBegin).width; + uint32_t total = height * width, idx = 0; + uint32_t startPos = 0; uint64_t indexBits = 0, runBitsIndex = 0, runBitsCopy = 0; m_storeCtx_Run = PLTCtx(m_orgCtxRD); PLTtypeBuf runType = tu.getrunType(compBegin); PelBuf runLength = tu.getrunLength(compBegin); - while (uiIdx < uiTotal) + while (idx < total) { - uiStartPos = uiIdx; - double dAveBitsPerPix[NUM_PLT_RUN]; - - uint32_t uiIndexRun = 0; - bool RunValid = calIndexRun(cs, partitioner, uiStartPos, uiTotal, uiIndexRun, compBegin); + startPos = idx; + double aveBitsPerPix[NUM_PLT_RUN]; + uint32_t indexRun = 0; + bool runValid = calIndexRun(cs, partitioner, startPos, total, indexRun, compBegin); m_CABACEstimator->getCtx() = PLTCtx(m_storeCtx_Run); - dAveBitsPerPix[PLT_RUN_INDEX] = RunValid ? getRunBits(cu, uiIndexRun, uiStartPos, PLT_RUN_INDEX, &indexBits, &runBitsIndex, compBegin) : MAX_DOUBLE; + aveBitsPerPix[PLT_RUN_INDEX] = runValid ? getRunBits(cu, indexRun, startPos, PLT_RUN_INDEX, &indexBits, &runBitsIndex, compBegin) : MAX_DOUBLE; m_storeCtx_RunIndex = PLTCtx(m_CABACEstimator->getCtx()); - uint32_t uiCopyRun = 0; - bool CopyValid = calCopyRun(cs, partitioner, uiStartPos, uiTotal, uiCopyRun, compBegin); + uint32_t copyRun = 0; + bool copyValid = calCopyRun(cs, partitioner, startPos, total, copyRun, compBegin); m_CABACEstimator->getCtx() = PLTCtx(m_storeCtx_Run); - dAveBitsPerPix[PLT_RUN_COPY] = CopyValid ? getRunBits(cu, uiCopyRun, uiStartPos, PLT_RUN_COPY, &indexBits, &runBitsCopy, compBegin) : MAX_DOUBLE; + aveBitsPerPix[PLT_RUN_COPY] = copyValid ? getRunBits(cu, copyRun, startPos, PLT_RUN_COPY, &indexBits, &runBitsCopy, compBegin) : MAX_DOUBLE; m_storeCtx_RunCopy = PLTCtx(m_CABACEstimator->getCtx()); - if (CopyValid == 0 && RunValid == 0) + if (copyValid == 0 && runValid == 0) { assert(0); } else { - if (dAveBitsPerPix[PLT_RUN_COPY] <= dAveBitsPerPix[PLT_RUN_INDEX]) + if (aveBitsPerPix[PLT_RUN_COPY] <= aveBitsPerPix[PLT_RUN_INDEX]) { - for (int runidx = 0; runidx <uiCopyRun; runidx++) + for (int runidx = 0; runidx <copyRun; runidx++) { - uint32_t posy = m_puiScanOrder[uiIdx + runidx].y; - uint32_t posx = m_puiScanOrder[uiIdx + runidx].x; + uint32_t posy = m_puiScanOrder[idx + runidx].y; + uint32_t posx = m_puiScanOrder[idx + runidx].x; runType.at(posx, posy) = PLT_RUN_COPY; - runLength.at(posx, posy) = uiCopyRun; + runLength.at(posx, posy) = copyRun; } - uiIdx += uiCopyRun; + idx += copyRun; m_storeCtx_Run = PLTCtx(m_storeCtx_RunCopy); } else { - for (int runidx = 0; runidx <uiIndexRun; runidx++) + for (int runidx = 0; runidx <indexRun; runidx++) { - uint32_t posy = m_puiScanOrder[uiIdx + runidx].y; - uint32_t posx = m_puiScanOrder[uiIdx + runidx].x; + uint32_t posy = m_puiScanOrder[idx + runidx].y; + uint32_t posx = m_puiScanOrder[idx + runidx].x; runType.at(posx, posy) = PLT_RUN_INDEX; - runLength.at(posx, posy) = uiIndexRun; + runLength.at(posx, posy) = indexRun; } - uiIdx += uiIndexRun; + idx += indexRun; m_storeCtx_Run = PLTCtx(m_storeCtx_RunIndex); } } } - assert(uiIdx == uiTotal); + assert(idx == total); } double IntraSearch::getRunBits(const CodingUnit& cu, uint32_t run, uint32_t strPos, PLTRunMode paletteRunMode, uint64_t* indexBits, uint64_t* runBits, ComponentID compBegin) { TransformUnit& tu = *cu.firstTU; - uint32_t uiHeight = cu.block(compBegin).height; - uint32_t uiWidth = cu.block(compBegin).width; - uint32_t endPos = uiHeight*uiWidth; - PLTtypeBuf runType = tu.getrunType(compBegin); - PelBuf curPLTIdx = tu.getcurPLTIdx(compBegin); - uint32_t uiIndexMaxSize = (cu.useEscape[compBegin]) ? (cu.curPLTSize[compBegin] + 1) : cu.curPLTSize[compBegin]; + uint32_t height = cu.block(compBegin).height; + uint32_t width = cu.block(compBegin).width; + uint32_t endPos = height*width; + PLTtypeBuf runType = tu.getrunType(compBegin); + PelBuf curPLTIdx = tu.getcurPLTIdx(compBegin); + uint32_t indexMaxSize = (cu.useEscape[compBegin]) ? (cu.curPLTSize[compBegin] + 1) : cu.curPLTSize[compBegin]; m_CABACEstimator->resetBits(); ///////////////// encode Run Type m_CABACEstimator->encodeRunType(cu, runType, strPos, m_puiScanOrder, compBegin); - uint64_t RunTypeBits = m_CABACEstimator->getEstFracBits(); + uint64_t runTypeBits = m_CABACEstimator->getEstFracBits(); uint32_t curLevel = 0; switch (paletteRunMode) { case PLT_RUN_INDEX: - curLevel = m_CABACEstimator->writePLTIndex(cu, strPos, curPLTIdx, runType, uiIndexMaxSize, compBegin); - *indexBits = m_CABACEstimator->getEstFracBits() - RunTypeBits; + curLevel = m_CABACEstimator->writePLTIndex(cu, strPos, curPLTIdx, runType, indexMaxSize, compBegin); + *indexBits = m_CABACEstimator->getEstFracBits() - runTypeBits; m_CABACEstimator->cu_run_val(run - 1, PLT_RUN_INDEX, curLevel, endPos - strPos - 1); - *runBits = m_CABACEstimator->getEstFracBits() - RunTypeBits - (*indexBits); + *runBits = m_CABACEstimator->getEstFracBits() - runTypeBits - (*indexBits); break; case PLT_RUN_COPY: m_CABACEstimator->cu_run_val(run - 1, PLT_RUN_COPY, curLevel, endPos - strPos - 1); - *runBits = m_CABACEstimator->getEstFracBits() - RunTypeBits; + *runBits = m_CABACEstimator->getEstFracBits() - runTypeBits; break; default: assert(0); } assert(run >= 1); - double dCostPerPixel = (double)m_CABACEstimator->getEstFracBits() / (double)run; - return dCostPerPixel; + double costPerPixel = (double)m_CABACEstimator->getEstFracBits() / (double)run; + return costPerPixel; } void IntraSearch::preCalcPLTIndex(CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp) { @@ -1709,8 +1704,8 @@ void IntraSearch::preCalcPLTIndex(CodingStructure& cs, Partitioner& partitioner, const int pcmShiftRight_L = (channelBitDepth_L - PLT_ENCBITDEPTH); const int pcmShiftRight_C = (channelBitDepth_C - PLT_ENCBITDEPTH); - uint32_t uiHeight = cu.block(compBegin).height; - uint32_t uiWidth = cu.block(compBegin).width; + uint32_t height = cu.block(compBegin).height; + uint32_t width = cu.block(compBegin).width; CPelBuf orgBuf[3]; for (int comp = compBegin; comp < (compBegin + numComp); comp++) @@ -1727,56 +1722,51 @@ void IntraSearch::preCalcPLTIndex(CodingStructure& cs, Partitioner& partitioner, } PelBuf curPLTIdx = tu.getcurPLTIdx(compBegin); - int iErrorLimit = numComp * g_uhPLTQuant[cu.qp]; - - uint32_t uiBestIdx = 0; - - + int errorLimit = numComp * g_uhPLTQuant[cu.qp]; + uint32_t bestIdx = 0; uint32_t scaleX = getComponentScaleX(COMPONENT_Cb, cs.sps->getChromaFormatIdc()); uint32_t scaleY = getComponentScaleY(COMPONENT_Cb, cs.sps->getChromaFormatIdc()); - for (uint32_t uiY = 0; uiY < uiHeight; uiY++) + for (uint32_t y = 0; y < height; y++) { - for (uint32_t uiX = 0; uiX < uiWidth; uiX++) + for (uint32_t x = 0; x < width; x++) { - uint32_t uiPLTIdx = 0; - uint32_t uiMinError = MAX_UINT; - while (uiPLTIdx < cu.curPLTSize[compBegin]) + uint32_t pltIdx = 0; + uint32_t minError = MAX_UINT; + while (pltIdx < cu.curPLTSize[compBegin]) { - uint32_t uiAbsError = 0, pX, pY; + uint32_t absError = 0, pX, pY; for (int comp = compBegin; comp < (compBegin + numComp); comp++) { - pX = (comp > 0 && compBegin == COMPONENT_Y) ? (uiX >> scaleX) : uiX; - pY = (comp > 0 && compBegin == COMPONENT_Y) ? (uiY >> scaleY) : uiY; + pX = (comp > 0 && compBegin == COMPONENT_Y) ? (x >> scaleX) : x; + pY = (comp > 0 && compBegin == COMPONENT_Y) ? (y >> scaleY) : y; int shift = (comp > 0) ? pcmShiftRight_C : pcmShiftRight_L; - uiAbsError += abs(cu.curPLT[comp][uiPLTIdx] - orgBuf[comp].at(pX, pY)) >> shift; + absError += abs(cu.curPLT[comp][pltIdx] - orgBuf[comp].at(pX, pY)) >> shift; } - if (uiAbsError < uiMinError) + if (absError < minError) { - uiBestIdx = uiPLTIdx; - uiMinError = uiAbsError; - if (uiMinError == 0) + bestIdx = pltIdx; + minError = absError; + if (minError == 0) { break; } } - uiPLTIdx++; + pltIdx++; } - curPLTIdx.at(uiX, uiY) = uiBestIdx; - - if (uiMinError > iErrorLimit) + curPLTIdx.at(x, y) = bestIdx; + if (minError > errorLimit) { - curPLTIdx.at(uiX, uiY) = cu.curPLTSize[compBegin]; + curPLTIdx.at(x, y) = cu.curPLTSize[compBegin]; cu.useEscape[compBegin] = true; - calcPixelPred(cs, partitioner, uiY, uiX, compBegin, numComp); + calcPixelPred(cs, partitioner, y, x, compBegin, numComp); } - } } } -void IntraSearch::calcPixelPred(CodingStructure& cs, Partitioner& partitioner, uint32_t uiY, uint32_t uiX, ComponentID compBegin, uint32_t numComp) +void IntraSearch::calcPixelPred(CodingStructure& cs, Partitioner& partitioner, uint32_t yPos, uint32_t xPos, ComponentID compBegin, uint32_t numComp) { - CodingUnit &cu = *cs.getCU(partitioner.chType); + CodingUnit &cu = *cs.getCU(partitioner.chType); TransformUnit &tu = *cs.getTU(partitioner.chType); CPelBuf orgBuf[3]; @@ -1793,51 +1783,50 @@ void IntraSearch::calcPixelPred(CodingStructure& cs, Partitioner& partitioner, u } } - int iQP[3]; - int iQPrem[3]; - int iQPper[3]; + int qp[3]; + int qpRem[3]; + int qpPer[3]; int quantiserScale[3]; int quantiserRightShift[3]; int rightShiftOffset[3]; int InvquantiserRightShift[3]; - int iAdd[3]; + int add[3]; for (uint32_t ch = compBegin; ch < (compBegin + numComp); ch++) { QpParam cQP(tu, ComponentID(ch)); - iQP[ch] = cQP.Qp; - iQPrem[ch] = iQP[ch] % 6; - iQPper[ch] = iQP[ch] / 6; - quantiserScale[ch] = g_quantScales[0][iQPrem[ch]]; - quantiserRightShift[ch] = QUANT_SHIFT + iQPper[ch]; + qp[ch] = cQP.Qp; + qpRem[ch] = qp[ch] % 6; + qpPer[ch] = qp[ch] / 6; + quantiserScale[ch] = g_quantScales[0][qpRem[ch]]; + quantiserRightShift[ch] = QUANT_SHIFT + qpPer[ch]; rightShiftOffset[ch] = 1 << (quantiserRightShift[ch] - 1); InvquantiserRightShift[ch] = IQUANT_SHIFT; - iAdd[ch] = 1 << (InvquantiserRightShift[ch] - 1); + add[ch] = 1 << (InvquantiserRightShift[ch] - 1); } uint32_t scaleX = getComponentScaleX(COMPONENT_Cb, cs.sps->getChromaFormatIdc()); uint32_t scaleY = getComponentScaleY(COMPONENT_Cb, cs.sps->getChromaFormatIdc()); - for (uint32_t ch = compBegin; ch < (compBegin + numComp); ch++) { - const int channelBitDepth = cu.cs->sps->getBitDepth(toChannelType((ComponentID)ch)); + const int channelBitDepth = cu.cs->sps->getBitDepth(toChannelType((ComponentID)ch)); CompArea area = cu.blocks[ch]; PelBuf recBuf = cs.getRecoBuf(area); - PLTescapeBuf escapeValue = tu.getescapeValue((ComponentID)ch); + PLTescapeBuf escapeValue = tu.getescapeValue((ComponentID)ch); if (compBegin != COMPONENT_Y || ch == 0) { - escapeValue.at(uiX, uiY) = TCoeff(std::max<int>(0, ((orgBuf[ch].at(uiX, uiY) * quantiserScale[ch] + rightShiftOffset[ch]) >> quantiserRightShift[ch]))); - assert(escapeValue.at(uiX, uiY) < (1 << (channelBitDepth + 1))); - recBuf.at(uiX, uiY) = (((escapeValue.at(uiX, uiY)*g_invQuantScales[0][iQPrem[ch]]) << iQPper[ch]) + iAdd[ch]) >> InvquantiserRightShift[ch]; - recBuf.at(uiX, uiY) = Pel(ClipBD<int>(recBuf.at(uiX, uiY), channelBitDepth));//to be checked + escapeValue.at(xPos, yPos) = TCoeff(std::max<int>(0, ((orgBuf[ch].at(xPos, yPos) * quantiserScale[ch] + rightShiftOffset[ch]) >> quantiserRightShift[ch]))); + assert(escapeValue.at(xPos, yPos) < (1 << (channelBitDepth + 1))); + recBuf.at(xPos, yPos) = (((escapeValue.at(xPos, yPos)*g_invQuantScales[0][qpRem[ch]]) << qpPer[ch]) + add[ch]) >> InvquantiserRightShift[ch]; + recBuf.at(xPos, yPos) = Pel(ClipBD<int>(recBuf.at(xPos, yPos), channelBitDepth));//to be checked } - else if (compBegin == COMPONENT_Y && ch > 0 && uiY % (1 << scaleY) == 0 && uiX % (1 << scaleX) == 0) + else if (compBegin == COMPONENT_Y && ch > 0 && yPos % (1 << scaleY) == 0 && xPos % (1 << scaleX) == 0) { - uint32_t uiYC = uiY >> scaleY; - uint32_t uiXC = uiX >> scaleX; - escapeValue.at(uiXC, uiYC) = TCoeff(std::max<int>(0, ((orgBuf[ch].at(uiXC, uiYC) * quantiserScale[ch] + rightShiftOffset[ch]) >> quantiserRightShift[ch]))); - assert(escapeValue.at(uiXC, uiYC) < (1 << (channelBitDepth + 1))); - recBuf.at(uiXC, uiYC) = (((escapeValue.at(uiXC, uiYC)*g_invQuantScales[0][iQPrem[ch]]) << iQPper[ch]) + iAdd[ch]) >> InvquantiserRightShift[ch]; - recBuf.at(uiXC, uiYC) = Pel(ClipBD<int>(recBuf.at(uiXC, uiYC), channelBitDepth));//to be checked + uint32_t yPosC = yPos >> scaleY; + uint32_t xPosC = xPos >> scaleX; + escapeValue.at(xPosC, yPosC) = TCoeff(std::max<int>(0, ((orgBuf[ch].at(xPosC, yPosC) * quantiserScale[ch] + rightShiftOffset[ch]) >> quantiserRightShift[ch]))); + assert(escapeValue.at(xPosC, yPosC) < (1 << (channelBitDepth + 1))); + recBuf.at(xPosC, yPosC) = (((escapeValue.at(xPosC, yPosC)*g_invQuantScales[0][qpRem[ch]]) << qpPer[ch]) + add[ch]) >> InvquantiserRightShift[ch]; + recBuf.at(xPosC, yPosC) = Pel(ClipBD<int>(recBuf.at(xPosC, yPosC), channelBitDepth));//to be checked } } } @@ -1849,8 +1838,8 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, const int pcmShiftRight_L = (channelBitDepth_L - PLT_ENCBITDEPTH); const int pcmShiftRight_C = (channelBitDepth_C - PLT_ENCBITDEPTH); - uint32_t uiHeight = cu.block(compBegin).height; - uint32_t uiWidth = cu.block(compBegin).width; + uint32_t height = cu.block(compBegin).height; + uint32_t width = cu.block(compBegin).width; CPelBuf orgBuf[3]; for (int comp = compBegin; comp < (compBegin + numComp); comp++) @@ -1866,36 +1855,35 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, } } - int iErrorLimit = g_uhPLTQuant[cu.qp]; - - uint32_t uiTotalSize = uiHeight*uiWidth; - SortingElement *psList = new SortingElement[uiTotalSize]; - SortingElement sElement; - uint32_t uiDictMaxSize = MAXPLTSIZE; - SortingElement *pListSort = new SortingElement[MAXPLTSIZE + 1]; - uint32_t uiIdx = 0; + int errorLimit = g_uhPLTQuant[cu.qp]; + uint32_t totalSize = height*width; + SortingElement *pelList = new SortingElement[totalSize]; + SortingElement element; + SortingElement *pelListSort = new SortingElement[MAXPLTSIZE + 1]; + uint32_t dictMaxSize = MAXPLTSIZE; + uint32_t idx = 0; int last = -1; uint32_t scaleX = getComponentScaleX(COMPONENT_Cb, cs.sps->getChromaFormatIdc()); uint32_t scaleY = getComponentScaleY(COMPONENT_Cb, cs.sps->getChromaFormatIdc()); - for (uint32_t uiY = 0; uiY < uiHeight; uiY++) + for (uint32_t y = 0; y < height; y++) { - for (uint32_t uiX = 0; uiX < uiWidth; uiX++) + for (uint32_t x = 0; x < width; x++) { - uint32_t paOrig[3], pX, pY; + uint32_t org[3], pX, pY; for (int comp = compBegin; comp < (compBegin + numComp); comp++) { - pX = (comp > 0 && compBegin == COMPONENT_Y) ? (uiX >> scaleX) : uiX; - pY = (comp > 0 && compBegin == COMPONENT_Y) ? (uiY >> scaleY) : uiY; - paOrig[comp] = orgBuf[comp].at(pX, pY); + 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); } - sElement.setAll(paOrig, compBegin, numComp); - int besti = last, bestSAD = (last == -1) ? MAX_UINT : psList[last].getSAD(sElement, cs.sps->getBitDepths(), compBegin, numComp); + element.setAll(org, compBegin, numComp); + int besti = last, bestSAD = (last == -1) ? MAX_UINT : pelList[last].getSAD(element, cs.sps->getBitDepths(), compBegin, numComp); if (bestSAD) { - for (int i = uiIdx - 1; i >= 0; i--) + for (int i = idx - 1; i >= 0; i--) { - uint32_t sad = psList[i].getSAD(sElement, cs.sps->getBitDepths(), compBegin, numComp); + uint32_t sad = pelList[i].getSAD(element, cs.sps->getBitDepths(), compBegin, numComp); if (sad < bestSAD) { bestSAD = sad; @@ -1904,51 +1892,51 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, } } } - if (besti >= 0 && psList[besti].almostEqualData(sElement, iErrorLimit, cs.sps->getBitDepths(), compBegin, numComp)) + if (besti >= 0 && pelList[besti].almostEqualData(element, errorLimit, cs.sps->getBitDepths(), compBegin, numComp)) { - psList[besti].addElement(sElement, compBegin, numComp); + pelList[besti].addElement(element, compBegin, numComp); last = besti; } else { - psList[uiIdx].copyDataFrom(sElement, compBegin, numComp); - psList[uiIdx].uiCnt = 1; - last = uiIdx; - uiIdx++; + pelList[idx].copyDataFrom(element, compBegin, numComp); + pelList[idx].cnt = 1; + last = idx; + idx++; } } } - for (int i = 0; i < uiDictMaxSize; i++) + for (int i = 0; i < dictMaxSize; i++) { - pListSort[i].uiCnt = 0; - pListSort[i].resetAll(compBegin, numComp); + pelListSort[i].cnt = 0; + pelListSort[i].resetAll(compBegin, numComp); } //bubble sorting - uiDictMaxSize = 1; - for (int i = 0; i < uiIdx; i++) + dictMaxSize = 1; + for (int i = 0; i < idx; i++) { - if (psList[i].uiCnt > pListSort[uiDictMaxSize - 1].uiCnt) + if (pelList[i].cnt > pelListSort[dictMaxSize - 1].cnt) { int j; - for (j = uiDictMaxSize; j > 0; j--) + for (j = dictMaxSize; j > 0; j--) { - if (psList[i].uiCnt > pListSort[j - 1].uiCnt) + if (pelList[i].cnt > pelListSort[j - 1].cnt) { - pListSort[j].copyAllFrom(pListSort[j - 1], compBegin, numComp); - uiDictMaxSize = std::min(uiDictMaxSize + 1, (uint32_t)MAXPLTSIZE); + pelListSort[j].copyAllFrom(pelListSort[j - 1], compBegin, numComp); + dictMaxSize = std::min(dictMaxSize + 1, (uint32_t)MAXPLTSIZE); } else { break; } } - pListSort[j].copyAllFrom(psList[i], compBegin, numComp); + pelListSort[j].copyAllFrom(pelList[i], compBegin, numComp); } } - uint32_t uiPLTSize = 0; + uint32_t paletteSize = 0; uint64_t numColorBits = 0; for (int comp = compBegin; comp < (compBegin + numComp); comp++) { @@ -1958,26 +1946,26 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, double bitCost = m_pcRdCost->getLambda()*numColorBits; for (int i = 0; i < MAXPLTSIZE; i++) { - if (pListSort[i].uiCnt) + if (pelListSort[i].cnt) { - int iHalf = pListSort[i].uiCnt >> 1; + int half = pelListSort[i].cnt >> 1; for (int comp = compBegin; comp < (compBegin + numComp); comp++) { - cu.curPLT[comp][uiPLTSize] = (pListSort[i].uiSumData[comp] + iHalf) / pListSort[i].uiCnt; + cu.curPLT[comp][paletteSize] = (pelListSort[i].sumData[comp] + half) / pelListSort[i].cnt; } int best = -1; - if (iErrorLimit) + if (errorLimit) { double pal[MAX_NUM_COMPONENT], err = 0.0, bestCost = 0.0; for (int comp = compBegin; comp < (compBegin + numComp); comp++) { const int shift = (comp > 0) ? pcmShiftRight_C : pcmShiftRight_L; - pal[comp] = pListSort[i].uiSumData[comp] / (double)pListSort[i].uiCnt; - err = pal[comp] - cu.curPLT[comp][uiPLTSize]; + pal[comp] = pelListSort[i].sumData[comp] / (double)pelListSort[i].cnt; + err = pal[comp] - cu.curPLT[comp][paletteSize]; bestCost += (err*err) / (1 << (2 * shift)); } - bestCost = bestCost * pListSort[i].uiCnt + bitCost; + bestCost = bestCost * pelListSort[i].cnt + bitCost; for (int t = 0; t < cs.prevPLT.curPLTSize[compBegin]; t++) { @@ -1988,7 +1976,7 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, err = pal[comp] - cs.prevPLT.curPLT[comp][t]; cost += (err*err) / (1 << (2 * shift)); } - cost *= pListSort[i].uiCnt; + cost *= pelListSort[i].cnt; if (cost < bestCost) { best = t; @@ -1999,43 +1987,43 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, { for (int comp = compBegin; comp < (compBegin + numComp); comp++) { - cu.curPLT[comp][uiPLTSize] = cs.prevPLT.curPLT[comp][best]; + cu.curPLT[comp][paletteSize] = cs.prevPLT.curPLT[comp][best]; } } } - bool bDuplicate = false; - if (pListSort[i].uiCnt == 1 && best == -1) + bool duplicate = false; + if (pelListSort[i].cnt == 1 && best == -1) { - bDuplicate = true; + duplicate = true; } else { - for (int t = 0; t<uiPLTSize; t++) + for (int t = 0; t<paletteSize; t++) { - bool bDuplicateTmp = true; + bool duplicateTmp = true; for (int comp = compBegin; comp < (compBegin + numComp); comp++) { - bDuplicateTmp = bDuplicateTmp && (cu.curPLT[comp][uiPLTSize] == cu.curPLT[comp][t]); + duplicateTmp = duplicateTmp && (cu.curPLT[comp][paletteSize] == cu.curPLT[comp][t]); } - if (bDuplicateTmp) + if (duplicateTmp) { - bDuplicate = true; + duplicate = true; break; } } } - if (!bDuplicate) uiPLTSize++; + if (!duplicate) paletteSize++; } else { break; } } - cu.curPLTSize[compBegin] = uiPLTSize; + cu.curPLTSize[compBegin] = paletteSize; - delete[] psList; - delete[] pListSort; + delete[] pelList; + delete[] pelListSort; } #endif // ------------------------------------------------------------------------------------------------------------------- diff --git a/source/Lib/EncoderLib/IntraSearch.h b/source/Lib/EncoderLib/IntraSearch.h index b2de527051f30eb9a09e229a4bf0ceb245d7509f..f7d5b46fbcce9ca76f7cc7c39c7d3d8cd123c451 100644 --- a/source/Lib/EncoderLib/IntraSearch.h +++ b/source/Lib/EncoderLib/IntraSearch.h @@ -68,89 +68,89 @@ enum PLTScanMode class SortingElement { public: - uint32_t uiCnt; - int uiData[3]; - int uiShift, uiLastCnt, uiSumData[3]; + uint32_t cnt; + int data[3]; + int shift, lastCnt, sumData[3]; inline bool operator<(const SortingElement &other) const { - return uiCnt > other.uiCnt; + return cnt > other.cnt; } SortingElement() { - uiCnt = uiShift = uiLastCnt = 0; - uiData[0] = uiData[1] = uiData[2] = 0; - uiSumData[0] = uiSumData[1] = uiSumData[2] = 0; + cnt = shift = lastCnt = 0; + data[0] = data[1] = data[2] = 0; + sumData[0] = sumData[1] = sumData[2] = 0; } void resetAll(ComponentID compBegin, uint32_t numComp) { - uiShift = uiLastCnt = 0; + shift = lastCnt = 0; for (int ch = compBegin; ch < (compBegin + numComp); ch++) { - uiData[ch] = 0; - uiSumData[ch] = 0; + data[ch] = 0; + sumData[ch] = 0; } } void setAll(uint32_t* ui, ComponentID compBegin, uint32_t numComp) { for (int ch = compBegin; ch < (compBegin + numComp); ch++) { - uiData[ch] = ui[ch]; + data[ch] = ui[ch]; } } - bool almostEqualData(SortingElement sElement, int iErrorLimit, const BitDepths& bitDepths, ComponentID compBegin, uint32_t numComp) + bool almostEqualData(SortingElement element, int errorLimit, const BitDepths& bitDepths, ComponentID compBegin, uint32_t numComp) { - bool bAlmostEqual = true; + bool almostEqual = true; for (int comp = compBegin; comp < (compBegin + numComp); comp++) { ChannelType chType = (comp > 0) ? CHANNEL_TYPE_CHROMA : CHANNEL_TYPE_LUMA; - if ((std::abs(uiData[comp] - sElement.uiData[comp]) >> (bitDepths.recon[chType] - PLT_ENCBITDEPTH)) > iErrorLimit) + if ((std::abs(data[comp] - element.data[comp]) >> (bitDepths.recon[chType] - PLT_ENCBITDEPTH)) > errorLimit) { - bAlmostEqual = false; + almostEqual = false; break; } } - return bAlmostEqual; + return almostEqual; } - uint32_t getSAD(SortingElement sElement, const BitDepths& bitDepths, ComponentID compBegin, uint32_t numComp) + uint32_t getSAD(SortingElement element, const BitDepths& bitDepths, ComponentID compBegin, uint32_t numComp) { - uint32_t uiSAD = 0; + uint32_t sumAd = 0; for (int comp = compBegin; comp < (compBegin + numComp); comp++) { ChannelType chType = (comp > 0) ? CHANNEL_TYPE_CHROMA : CHANNEL_TYPE_LUMA; - uiSAD += (std::abs(uiData[comp] - sElement.uiData[comp]) >> (bitDepths.recon[chType] - PLT_ENCBITDEPTH)); + sumAd += (std::abs(data[comp] - element.data[comp]) >> (bitDepths.recon[chType] - PLT_ENCBITDEPTH)); } - return uiSAD; + return sumAd; } - void copyDataFrom(SortingElement sElement, ComponentID compBegin, uint32_t numComp) { + void copyDataFrom(SortingElement element, ComponentID compBegin, uint32_t numComp) { for (int comp = compBegin; comp < (compBegin + numComp); comp++) { - uiData[comp] = sElement.uiData[comp]; - uiSumData[comp] = uiData[comp]; + data[comp] = element.data[comp]; + sumData[comp] = data[comp]; } - uiShift = 0; uiLastCnt = 1; + shift = 0; lastCnt = 1; } - void copyAllFrom(SortingElement sElement, ComponentID compBegin, uint32_t numComp) { - copyDataFrom(sElement, compBegin, numComp); - uiCnt = sElement.uiCnt; + void copyAllFrom(SortingElement element, ComponentID compBegin, uint32_t numComp) { + copyDataFrom(element, compBegin, numComp); + cnt = element.cnt; for (int comp = compBegin; comp < (compBegin + numComp); comp++) { - uiSumData[comp] = sElement.uiSumData[comp]; + sumData[comp] = element.sumData[comp]; } - uiLastCnt = sElement.uiLastCnt; uiShift = sElement.uiShift; + lastCnt = element.lastCnt; shift = element.shift; } - void addElement(const SortingElement& sElement, ComponentID compBegin, uint32_t numComp) + void addElement(const SortingElement& element, ComponentID compBegin, uint32_t numComp) { - uiCnt++; + cnt++; for (int i = compBegin; i<(compBegin + numComp); i++) { - uiSumData[i] += sElement.uiData[i]; + sumData[i] += element.data[i]; } - if (uiCnt>1 && uiCnt == 2 * uiLastCnt) + if (cnt>1 && cnt == 2 * lastCnt) { - uint32_t uiRnd = 1 << uiShift; - uiShift++; + uint32_t rnd = 1 << shift; + shift++; for (int i = compBegin; i<(compBegin + numComp); i++) { - uiData[i] = (uiSumData[i] + uiRnd) >> uiShift; + data[i] = (sumData[i] + rnd) >> shift; } - uiLastCnt = uiCnt; + lastCnt = cnt; } } }; @@ -251,7 +251,7 @@ public: void IPCMSearch (CodingStructure &cs, Partitioner& partitioner); #if JVET_O0119_BASE_PALETTE_444 void PLTSearch ( CodingStructure &cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp); - void deriveRunAndCalcBits ( CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp, PLTScanMode pltScanMode, uint64_t& uiBits); + void deriveRunAndCalcBits ( CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp, PLTScanMode pltScanMode, uint64_t& bits); #endif uint64_t xFracModeBitsIntra (PredictionUnit &pu, const uint32_t &uiMode, const ChannelType &compID); @@ -292,9 +292,9 @@ protected: #if JVET_O0119_BASE_PALETTE_444 void deriveRun(CodingStructure &cs, Partitioner& partitioner, ComponentID compBegin); double getRunBits(const CodingUnit& cu, uint32_t run, uint32_t strPos, PLTRunMode paletteRunMode, uint64_t* indexBits, uint64_t* runBits, ComponentID compBegin); - void derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp); - void calcPixelPred(CodingStructure& cs, Partitioner& partitioner, uint32_t uiY, uint32_t uiX, ComponentID compBegin, uint32_t numComp); - void preCalcPLTIndex(CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp); + void derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp); + void calcPixelPred(CodingStructure& cs, Partitioner& partitioner, uint32_t yPos, uint32_t xPos, ComponentID compBegin, uint32_t numComp); + void preCalcPLTIndex(CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp); #endif };// END CLASS DEFINITION EncSearch