[x265] [PATCH] entropy: fix bugs in accumulation of misc bits in 1st pass
aarthi at multicorewareinc.com
aarthi at multicorewareinc.com
Tue Oct 27 13:20:23 CET 2015
# HG changeset patch
# User Aarthi Thirumalai
# Date 1445948071 -19800
# Tue Oct 27 17:44:31 2015 +0530
# Node ID 773d56aede9ef60f20aa8bd4cb86b436d76f31fe
# Parent 6563218ce342c30bfd4f9bc172a1dab510e6e55b
entropy: fix bugs in accumulation of misc bits in 1st pass
diff -r 6563218ce342 -r 773d56aede9e source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp Mon Oct 26 12:13:53 2015 +0530
+++ b/source/encoder/analysis.cpp Tue Oct 27 17:44:31 2015 +0530
@@ -2020,7 +2020,6 @@
mode.contexts.resetBits();
mode.contexts.codeSplitFlag(mode.cu, 0, depth);
uint32_t bits = mode.contexts.getNumberOfWrittenBits();
- mode.mvBits += bits;
mode.totalBits += bits;
updateModeCost(mode);
}
@@ -2031,7 +2030,6 @@
}
else
{
- mode.mvBits++;
mode.totalBits++;
updateModeCost(mode);
}
diff -r 6563218ce342 -r 773d56aede9e source/encoder/search.cpp
--- a/source/encoder/search.cpp Mon Oct 26 12:13:53 2015 +0530
+++ b/source/encoder/search.cpp Tue Oct 27 17:44:31 2015 +0530
@@ -1177,21 +1177,23 @@
if (m_slice->m_pps->bTransquantBypassEnabled)
m_entropyCoder.codeCUTransquantBypassFlag(cu.m_tqBypass[0]);
+ int skipFlagBits = 0;
if (!m_slice->isIntra())
{
m_entropyCoder.codeSkipFlag(cu, 0);
+ skipFlagBits = m_entropyCoder.getNumberOfWrittenBits();
m_entropyCoder.codePredMode(cu.m_predMode[0]);
}
m_entropyCoder.codePartSize(cu, 0, cuGeom.depth);
m_entropyCoder.codePredInfo(cu, 0);
- intraMode.mvBits = m_entropyCoder.getNumberOfWrittenBits();
+ intraMode.mvBits = m_entropyCoder.getNumberOfWrittenBits() - skipFlagBits;
bool bCodeDQP = m_slice->m_pps->bUseDQP;
m_entropyCoder.codeCoeff(cu, 0, bCodeDQP, tuDepthRange);
m_entropyCoder.store(intraMode.contexts);
intraMode.totalBits = m_entropyCoder.getNumberOfWrittenBits();
- intraMode.coeffBits = intraMode.totalBits - intraMode.mvBits;
+ intraMode.coeffBits = intraMode.totalBits - intraMode.mvBits - skipFlagBits;
if (m_rdCost.m_psyRd)
{
const Yuv* fencYuv = intraMode.fencYuv;
@@ -1395,16 +1397,17 @@
if (m_slice->m_pps->bTransquantBypassEnabled)
m_entropyCoder.codeCUTransquantBypassFlag(cu.m_tqBypass[0]);
m_entropyCoder.codeSkipFlag(cu, 0);
+ int skipFlagBits = m_entropyCoder.getNumberOfWrittenBits();
m_entropyCoder.codePredMode(cu.m_predMode[0]);
m_entropyCoder.codePartSize(cu, 0, cuGeom.depth);
m_entropyCoder.codePredInfo(cu, 0);
- intraMode.mvBits += m_entropyCoder.getNumberOfWrittenBits();
+ intraMode.mvBits = m_entropyCoder.getNumberOfWrittenBits() - skipFlagBits;
bool bCodeDQP = m_slice->m_pps->bUseDQP;
m_entropyCoder.codeCoeff(cu, 0, bCodeDQP, tuDepthRange);
intraMode.totalBits = m_entropyCoder.getNumberOfWrittenBits();
- intraMode.coeffBits = intraMode.totalBits - intraMode.mvBits;
+ intraMode.coeffBits = intraMode.totalBits - intraMode.mvBits - skipFlagBits;
if (m_rdCost.m_psyRd)
{
const Yuv* fencYuv = intraMode.fencYuv;
@@ -2519,11 +2522,11 @@
if (m_slice->m_pps->bTransquantBypassEnabled)
m_entropyCoder.codeCUTransquantBypassFlag(cu.m_tqBypass[0]);
m_entropyCoder.codeSkipFlag(cu, 0);
+ int skipFlagBits = m_entropyCoder.getNumberOfWrittenBits();
m_entropyCoder.codeMergeIndex(cu, 0);
-
- interMode.mvBits = m_entropyCoder.getNumberOfWrittenBits();
+ interMode.mvBits = m_entropyCoder.getNumberOfWrittenBits() - skipFlagBits;
interMode.coeffBits = 0;
- interMode.totalBits = interMode.mvBits;
+ interMode.totalBits = interMode.mvBits + skipFlagBits;
if (m_rdCost.m_psyRd)
interMode.psyEnergy = m_rdCost.psyCost(part, fencYuv->m_buf[0], fencYuv->m_size, reconYuv->m_buf[0], reconYuv->m_size);
interMode.resEnergy = primitives.cu[part].sse_pp(fencYuv->m_buf[0], fencYuv->m_size, predYuv->m_buf[0], predYuv->m_size);
@@ -2599,30 +2602,33 @@
if (m_slice->m_pps->bTransquantBypassEnabled)
m_entropyCoder.codeCUTransquantBypassFlag(tqBypass);
- uint32_t coeffBits, bits;
+ uint32_t coeffBits, bits, mvBits;
if (cu.m_mergeFlag[0] && cu.m_partSize[0] == SIZE_2Nx2N && !cu.getQtRootCbf(0))
{
cu.setPredModeSubParts(MODE_SKIP);
/* Merge/Skip */
+ coeffBits = mvBits = 0;
m_entropyCoder.codeSkipFlag(cu, 0);
+ int skipFlagBits = m_entropyCoder.getNumberOfWrittenBits();
m_entropyCoder.codeMergeIndex(cu, 0);
- coeffBits = 0;
- bits = m_entropyCoder.getNumberOfWrittenBits();
+ mvBits = m_entropyCoder.getNumberOfWrittenBits() - skipFlagBits;
+ bits = mvBits + skipFlagBits;
}
else
{
m_entropyCoder.codeSkipFlag(cu, 0);
+ int skipFlagBits = m_entropyCoder.getNumberOfWrittenBits();
m_entropyCoder.codePredMode(cu.m_predMode[0]);
m_entropyCoder.codePartSize(cu, 0, cuGeom.depth);
m_entropyCoder.codePredInfo(cu, 0);
- uint32_t mvBits = m_entropyCoder.getNumberOfWrittenBits();
+ mvBits = m_entropyCoder.getNumberOfWrittenBits() - skipFlagBits;
bool bCodeDQP = m_slice->m_pps->bUseDQP;
m_entropyCoder.codeCoeff(cu, 0, bCodeDQP, tuDepthRange);
bits = m_entropyCoder.getNumberOfWrittenBits();
- coeffBits = bits - mvBits;
+ coeffBits = bits - mvBits - skipFlagBits;
}
m_entropyCoder.store(interMode.contexts);
@@ -2644,7 +2650,7 @@
interMode.chromaDistortion = bestChromaDist;
interMode.distortion = bestLumaDist + bestChromaDist;
interMode.coeffBits = coeffBits;
- interMode.mvBits = bits - coeffBits;
+ interMode.mvBits = mvBits;
updateModeCost(interMode);
checkDQP(interMode, cuGeom);
}
@@ -3477,7 +3483,6 @@
mode.contexts.resetBits();
mode.contexts.codeDeltaQP(cu, 0);
uint32_t bits = mode.contexts.getNumberOfWrittenBits();
- mode.mvBits += bits;
mode.totalBits += bits;
updateModeCost(mode);
}
@@ -3488,7 +3493,6 @@
}
else
{
- mode.mvBits++;
mode.totalBits++;
updateModeCost(mode);
}
@@ -3522,7 +3526,6 @@
mode.contexts.resetBits();
mode.contexts.codeDeltaQP(cu, 0);
uint32_t bits = mode.contexts.getNumberOfWrittenBits();
- mode.mvBits += bits;
mode.totalBits += bits;
updateModeCost(mode);
}
@@ -3533,7 +3536,6 @@
}
else
{
- mode.mvBits++;
mode.totalBits++;
updateModeCost(mode);
}
More information about the x265-devel
mailing list