diff --git a/source/Lib/CommonLib/Picture.cpp b/source/Lib/CommonLib/Picture.cpp index dbfa2da6c5edc66dd09230f3dcee5562cafd85d7..48cd7befba3929bef61a245a431916633889552b 100644 --- a/source/Lib/CommonLib/Picture.cpp +++ b/source/Lib/CommonLib/Picture.cpp @@ -232,9 +232,6 @@ const CPelBuf Picture::getFilteredOrigBuf(const CompArea &blk) const { retu const CPelBuf Picture::getPredBuf(const CompArea &blk) const { return getBuf(blk, PIC_PREDICTION); } PelUnitBuf Picture::getPredBuf(const UnitArea &unit) { return getBuf(unit, PIC_PREDICTION); } const CPelUnitBuf Picture::getPredBuf(const UnitArea &unit) const { return getBuf(unit, PIC_PREDICTION); } -#if JVET_AH0078_DPF -const CPelUnitBuf Picture::getPredBuf() const { return M_BUFS(0, PIC_PREDICTION); } -#endif PelBuf Picture::getResiBuf(const CompArea &blk) { return getBuf(blk, PIC_RESIDUAL); } const CPelBuf Picture::getResiBuf(const CompArea &blk) const { return getBuf(blk, PIC_RESIDUAL); } diff --git a/source/Lib/CommonLib/Picture.h b/source/Lib/CommonLib/Picture.h index 006f266d861f035161b8cd03b5b856eb199d6599..7aa9f38cc8b5a4832ed0500d64742f3937d4fea0 100644 --- a/source/Lib/CommonLib/Picture.h +++ b/source/Lib/CommonLib/Picture.h @@ -123,9 +123,6 @@ struct Picture : public UnitArea const CPelBuf getPredBuf(const CompArea &blk) const; PelUnitBuf getPredBuf(const UnitArea &unit); const CPelUnitBuf getPredBuf(const UnitArea &unit) const; -#if JVET_AH0078_DPF - const CPelUnitBuf getPredBuf() const; -#endif PelBuf getResiBuf(const CompArea &blk); const CPelBuf getResiBuf(const CompArea &blk) const; diff --git a/source/Lib/EncoderLib/EncSlice.cpp b/source/Lib/EncoderLib/EncSlice.cpp index b37d8566224c1c5719b4612aa0e8f27ef30e047f..f7abae280d510c3b42bda881f75241d21c63d7c1 100644 --- a/source/Lib/EncoderLib/EncSlice.cpp +++ b/source/Lib/EncoderLib/EncSlice.cpp @@ -131,13 +131,8 @@ void EncSlice::init( EncLib* pcEncLib, const SPS& sps ) #if JVET_AH0078_DPF if (m_pcCfg->getDPF()) { - const int sizeCu = m_pcCfg->getCTUSize(); const int height = m_pcCfg->getSourceHeight(); const int width = m_pcCfg->getSourceWidth(); - const int numCuHeight = height % sizeCu == 0 ? height / sizeCu : height / sizeCu + 1; - const int numCuWidth = width % sizeCu == 0 ? width / sizeCu : width / sizeCu + 1; - const int numCuPic = numCuHeight * numCuWidth; - m_lambdaWeight.assign(numCuPic, 1.0); m_pixelPredErr = new int*[height]; m_pixelRecDis = new int*[height]; for (int i = 0; i < height; i++) @@ -2071,26 +2066,17 @@ void EncSlice::encodeCtus( Picture* pcPic, const bool bCompressEntireSlice, cons } } #if JVET_AH0078_DPF - // merge clipped pred buffer if (m_pcCfg->getDPF() && m_pcLib->getEncType() == ENC_PRE) { - PelBuf& dstPreY = m_pre.get(COMPONENT_Y); - PelBuf dstPrePB(dstPreY.bufAt(0, 0), dstPreY.stride, dstPreY.width, dstPreY.height); - Pel* dstp = dstPrePB.bufAt(0, 0); - const CPelUnitBuf& srcPre = pcPic->getPredBuf(); - const CPelBuf& srcPreY = srcPre.get(COMPONENT_Y); - const CPelBuf srcPrePB(srcPreY.bufAt(0, 0), srcPreY.stride, srcPreY.width, srcPreY.height);; - const Pel* srcp = srcPrePB.bufAt(0, 0); - dstp += pos.y * dstPrePB.stride; - for (int y = 0; y < srcPreY.height && pos.y + y < dstPreY.height; y++) - { - for (int x = 0; x < srcPreY.width && pos.x + x < dstPreY.width; x++) - { - dstp[pos.x + x] = srcp[x]; - } - dstp += dstPrePB.stride; - srcp += srcPrePB.stride; - } + // merge clipped pred buffer + const int width = m_pcCfg->getSourceWidth(); + const int height = m_pcCfg->getSourceHeight(); + const int clipWidth = std::min((int)pcv.maxCUWidth, width - pos.x); + const int clipHeight = std::min((int)pcv.maxCUHeight, height - pos.y); + const UnitArea clipArea(cs.area.chromaFormat, Area(pos.x, pos.y, clipWidth, clipHeight)); + PelUnitBuf dstBuf = m_pre.subBuf(clipArea); + CPelUnitBuf srcBuf = pcPic->getPredBuf(clipArea); + dstBuf.copyFrom(srcBuf, true); } #endif } @@ -2263,34 +2249,22 @@ void EncSlice::estLamWt(Picture* pcPic) return; } - int curPOC = pcPic->getPOC(); - int gopSize = m_pcCfg->getGOPSize(); - int rPOC = curPOC % gopSize; - int numPropa = 0; - if (rPOC == 0) - { - numPropa = m_pcCfg->getDPFKeyLen(); - } - else - { - numPropa = m_pcCfg->getDPFNonkeyLen(); - } + const int curPOC = pcPic->getPOC(); + const int gopSize = m_pcCfg->getGOPSize(); + const int rPOC = curPOC % gopSize; + const int numPropa = rPOC == 0 ? m_pcCfg->getDPFKeyLen() : m_pcCfg->getDPFNonkeyLen(); const int width = m_pcCfg->getSourceWidth(); const int height = m_pcCfg->getSourceHeight(); const int sizeBlk = 32; - const int numBlkWidth = width % sizeBlk == 0 ? width / sizeBlk : width / sizeBlk + 1; - const int numBlkHeight = height % sizeBlk == 0 ? height / sizeBlk : height / sizeBlk + 1; - const int numBlkPic = numBlkWidth * numBlkHeight; - const int sizeCu = m_pcCfg->getCTUSize(); - const int numCuHeight = height % sizeCu == 0 ? height / sizeCu : height / sizeCu + 1; - const int numCuWidth = width % sizeCu == 0 ? width / sizeCu : width / sizeCu + 1; - const int numCuPic = numCuHeight * numCuWidth; - for (int idxCu = 0; idxCu < numCuPic; idxCu++) - { - m_lambdaWeight[idxCu] = 1.0; - } + const int numBlkWidth = (width + sizeBlk - 1) / sizeBlk; + const int numBlkHeight = (height + sizeBlk - 1) / sizeBlk; + const int numCuWidth = (width + sizeCu - 1) / sizeCu; + const int numCuHeight = (height + sizeCu - 1) / sizeCu; + const int numBlkPic = numBlkWidth * numBlkHeight; + const int numCuPic = numCuWidth * numCuHeight; + m_lambdaWeight.assign(numCuPic, 1.0); if (numPropa == 0) { @@ -2339,26 +2313,15 @@ void EncSlice::estLamWt(Picture* pcPic) const CPelBuf& recY = rec.get(COMPONENT_Y); const CPelBuf& preY = m_pre.get(COMPONENT_Y); - const CPelBuf orgPB(orgY.bufAt(0, 0), orgY.stride, orgY.width, orgY.height); - const CPelBuf recPB(recY.bufAt(0, 0), recY.stride, recY.width, recY.height); - const CPelBuf prePB(preY.bufAt(0, 0), preY.stride, preY.width, preY.height); - - const Pel* pOrg = orgPB.bufAt(0, 0); - const Pel* pRec = recPB.bufAt(0, 0); - const Pel* pPre = prePB.bufAt(0, 0); - for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { - Intermediate_Int err = pOrg[x] - pPre[x]; - Intermediate_Int dis = pOrg[x] - pRec[x]; + Intermediate_Int err = *orgY.bufAt(x, y) - *preY.bufAt(x, y); + Intermediate_Int dis = *orgY.bufAt(x, y) - *recY.bufAt(x, y); m_pixelPredErr[y][x] = err * err; m_pixelRecDis[y][x] = dis * dis; } - pOrg += orgPB.stride; - pPre += prePB.stride; - pRec += recPB.stride; } m_factorBlk.assign(numBlkPic, 0); @@ -2372,11 +2335,9 @@ void EncSlice::estLamWt(Picture* pcPic) int sumPixelPredErrBlk = 0; // block MCP error pHeightX_Blk = line; pWidthY_Blk = bIdx - line * numBlkWidth; - for (int i = pHeightX_Blk * sizeBlk; - i < (((pHeightX_Blk * sizeBlk + sizeBlk) <= height) ? (pHeightX_Blk * sizeBlk + sizeBlk) : height); i++) + for (int i = pHeightX_Blk * sizeBlk; i < std::min(pHeightX_Blk * sizeBlk + sizeBlk, height); i++) { - for (int j = pWidthY_Blk * sizeBlk; - j < (((pWidthY_Blk * sizeBlk + sizeBlk) <= width) ? (pWidthY_Blk * sizeBlk + sizeBlk) : width); j++) + for (int j = pWidthY_Blk * sizeBlk; j < std::min(pWidthY_Blk * sizeBlk + sizeBlk, width); j++) { sumPixelRecDisBlk += m_pixelRecDis[i][j]; sumPixelPredErrBlk += m_pixelPredErr[i][j];