[x265] [PATCH] rc: accumulate mv bits, coeff bits per frame

aarthi at multicorewareinc.com aarthi at multicorewareinc.com
Mon Jun 30 18:37:43 CEST 2014


# HG changeset patch
# User Aarthi Thirumalai<aarthi at multicorewareinc.com>
# Date 1403808050 -19800
#      Fri Jun 27 00:10:50 2014 +0530
# Node ID f6357a1be2b6a2d42245c08292ccfa2513e81da6
# Parent  502dec1dfaa3b68ebb068c7584cd37cb1a694f25
rc: accumulate mv bits, coeff bits per frame

diff -r 502dec1dfaa3 -r f6357a1be2b6 source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp	Mon Jun 30 13:03:06 2014 +0530
+++ b/source/Lib/TLibEncoder/TEncCu.cpp	Fri Jun 27 00:10:50 2014 +0530
@@ -1365,12 +1365,14 @@
     m_entropyCoder->encodePredMode(outTempCU, 0);
     m_entropyCoder->encodePartSize(outTempCU, 0, depth);
     m_entropyCoder->encodePredInfo(outTempCU, 0);
+    outTempCU->m_mvBits = m_entropyCoder->getNumberOfWrittenBits();
 
     // Encode Coefficients
     bool bCodeDQP = getdQPFlag();
     m_entropyCoder->encodeCoeff(outTempCU, 0, depth, outTempCU->getCUSize(0), bCodeDQP);
     m_rdGoOnSbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
     outTempCU->m_totalBits = m_entropyCoder->getNumberOfWrittenBits();
+    outTempCU->m_coeffBits = outTempCU->m_totalBits - outTempCU->m_mvBits;
 
     if (m_rdCost->psyRdEnabled())
     {
@@ -1411,12 +1413,14 @@
     m_entropyCoder->encodePredMode(outTempCU, 0);
     m_entropyCoder->encodePartSize(outTempCU, 0, depth);
     m_entropyCoder->encodePredInfo(outTempCU, 0);
+    outTempCU->m_mvBits = m_entropyCoder->getNumberOfWrittenBits();
 
     // Encode Coefficients
     bool bCodeDQP = getdQPFlag();
     m_entropyCoder->encodeCoeff(outTempCU, 0, depth, outTempCU->getCUSize(0), bCodeDQP);
     m_rdGoOnSbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
     outTempCU->m_totalBits = m_entropyCoder->getNumberOfWrittenBits();
+    outTempCU->m_coeffBits = outTempCU->m_totalBits - outTempCU->m_mvBits;
 
     if (m_rdCost->psyRdEnabled())
     {
diff -r 502dec1dfaa3 -r f6357a1be2b6 source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp	Mon Jun 30 13:03:06 2014 +0530
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp	Fri Jun 27 00:10:50 2014 +0530
@@ -4020,6 +4020,7 @@
         }
         m_entropyCoder->encodeSkipFlag(cu, 0);
         m_entropyCoder->encodeMergeIndex(cu, 0);
+        cu->m_mvBits = m_entropyCoder->getNumberOfWrittenBits();
         return m_entropyCoder->getNumberOfWrittenBits();
     }
     else
@@ -4034,8 +4035,11 @@
         m_entropyCoder->encodePartSize(cu, 0, cu->getDepth(0));
         m_entropyCoder->encodePredInfo(cu, 0);
         bool bDummy = false;
+        cu->m_mvBits = m_entropyCoder->getNumberOfWrittenBits();
         m_entropyCoder->encodeCoeff(cu, 0, cu->getDepth(0), cu->getCUSize(0), bDummy);
-        return m_entropyCoder->getNumberOfWrittenBits();
+        int totalBits = m_entropyCoder->getNumberOfWrittenBits();
+        cu->m_coeffBits = totalBits - cu->m_mvBits;
+        return totalBits;
     }
 }
 
diff -r 502dec1dfaa3 -r f6357a1be2b6 source/encoder/compress.cpp
--- a/source/encoder/compress.cpp	Mon Jun 30 13:03:06 2014 +0530
+++ b/source/encoder/compress.cpp	Fri Jun 27 00:10:50 2014 +0530
@@ -63,6 +63,7 @@
     m_entropyCoder->encodePredMode(cu, 0);
     m_entropyCoder->encodePartSize(cu, 0, depth);
     m_entropyCoder->encodePredInfo(cu, 0);
+    cu->m_mvBits += m_entropyCoder->getNumberOfWrittenBits();
 
     // Encode Coefficients
     bool bCodeDQP = getdQPFlag();
@@ -71,6 +72,7 @@
     m_rdGoOnSbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
 
     cu->m_totalBits = m_entropyCoder->getNumberOfWrittenBits();
+    cu->m_coeffBits = cu->m_totalBits - cu->m_mvBits;
     if (m_rdCost->psyRdEnabled())
     {
         int part = g_convertToBit[cu->getCUSize(0)];
diff -r 502dec1dfaa3 -r f6357a1be2b6 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Mon Jun 30 13:03:06 2014 +0530
+++ b/source/encoder/frameencoder.cpp	Fri Jun 27 00:10:50 2014 +0530
@@ -696,6 +696,11 @@
         // Store probabilities of second LCU in line into buffer
         if (col == 1 && m_param->bEnableWavefront)
             getBufferSBac(lin)->loadContexts(getSbacCoder(subStrm));
+
+        // Collect Frame Stats for 2 pass
+        m_frame->m_stats.mvBits += cu->m_mvBits;
+        m_frame->m_stats.coeffBits += cu->m_coeffBits;
+        m_frame->m_stats.miscBits += cu->m_totalBits - (cu->m_mvBits + cu->m_coeffBits);
     }
 
     if (slice->getPPS()->getCabacInitPresentFlag())


More information about the x265-devel mailing list