[x265] remove broadcast of non-leaf CBF

Satoshi Nakagawa nakagawa424 at oki.com
Fri Mar 25 03:25:33 CET 2016


# HG changeset patch
# User Satoshi Nakagawa <nakagawa424 at oki.com>
# Date 1458869254 -32400
#      Fri Mar 25 10:27:34 2016 +0900
# Node ID a2acf2e18b329b39f9e69d2ea818d834179b8a77
# Parent  c8ec86965e546f271ef54bad508a82e8a4911008
remove broadcast of non-leaf CBF

diff -r c8ec86965e54 -r a2acf2e18b32 source/common/cudata.h
--- a/source/common/cudata.h	Fri Feb 19 14:36:52 2016 +0530
+++ b/source/common/cudata.h	Fri Mar 25 10:27:34 2016 +0900
@@ -247,7 +247,7 @@
     void     setPURefIdx(int list, int8_t refIdx, int absPartIdx, int puIdx);
 
     uint8_t  getCbf(uint32_t absPartIdx, TextType ttype, uint32_t tuDepth) const { return (m_cbf[ttype][absPartIdx] >> tuDepth) & 0x1; }
-    uint8_t  getQtRootCbf(uint32_t absPartIdx) const                             { if (m_chromaFormat == X265_CSP_I400) return m_cbf[0][absPartIdx] || false; else { return m_cbf[0][absPartIdx] || m_cbf[1][absPartIdx] || m_cbf[2][absPartIdx];} }
+    bool     getQtRootCbf(uint32_t absPartIdx) const                             { return (m_cbf[0][absPartIdx] || ((m_chromaFormat != X265_CSP_I400) && (m_cbf[1][absPartIdx] || m_cbf[2][absPartIdx]))); }
     int8_t   getRefQP(uint32_t currAbsIdxInCTU) const;
     uint32_t getInterMergeCandidates(uint32_t absPartIdx, uint32_t puIdx, MVField (*candMvField)[2], uint8_t* candDir) const;
     void     clipMv(MV& outMV) const;
diff -r c8ec86965e54 -r a2acf2e18b32 source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp	Fri Feb 19 14:36:52 2016 +0530
+++ b/source/encoder/entropy.cpp	Fri Mar 25 10:27:34 2016 +0900
@@ -721,16 +721,12 @@
     bool bSmallChroma = (log2CurSize - hChromaShift) < 2;
     if (!curDepth || !bSmallChroma)
     {
-        if (!curDepth || cu.getCbf(absPartIdx, TEXT_CHROMA_U, curDepth - 1))
+        uint32_t parentIdx = absPartIdx & (0xFF << (log2CurSize + 1 - LOG2_UNIT_SIZE) * 2);
+        if (!curDepth || cu.getCbf(parentIdx, TEXT_CHROMA_U, curDepth - 1))
             codeQtCbfChroma(cu, absPartIdx, TEXT_CHROMA_U, curDepth, !subdiv);
-        if (!curDepth || cu.getCbf(absPartIdx, TEXT_CHROMA_V, curDepth - 1))
+        if (!curDepth || cu.getCbf(parentIdx, TEXT_CHROMA_V, curDepth - 1))
             codeQtCbfChroma(cu, absPartIdx, TEXT_CHROMA_V, curDepth, !subdiv);
     }
-    else
-    {
-        X265_CHECK(cu.getCbf(absPartIdx, TEXT_CHROMA_U, curDepth) == cu.getCbf(absPartIdx, TEXT_CHROMA_U, curDepth - 1), "chroma xform size match failure\n");
-        X265_CHECK(cu.getCbf(absPartIdx, TEXT_CHROMA_V, curDepth) == cu.getCbf(absPartIdx, TEXT_CHROMA_V, curDepth - 1), "chroma xform size match failure\n");
-    }
 
     if (subdiv)
     {
@@ -753,7 +749,7 @@
         X265_CHECK(cu.getCbf(absPartIdxC, TEXT_LUMA, 0), "CBF should have been set\n");
     }
     else
-        codeQtCbfLuma(cu, absPartIdx, curDepth);
+        codeQtCbfLuma(cu.getCbf(absPartIdx, TEXT_LUMA, curDepth), curDepth);
 
     uint32_t cbfY = cu.getCbf(absPartIdx, TEXT_LUMA, curDepth);
     uint32_t cbfU = cu.getCbf(absPartIdxC, TEXT_CHROMA_U, curDepth);
@@ -874,7 +870,7 @@
         X265_CHECK(cu.getCbf(absPartIdx, TEXT_LUMA, 0), "CBF should have been set\n");
     }
     else
-        codeQtCbfLuma(cu, absPartIdx, curDepth);
+        codeQtCbfLuma(cu.getCbf(absPartIdx, TEXT_LUMA, curDepth), curDepth);
 
     uint32_t cbfY = cu.getCbf(absPartIdx, TEXT_LUMA, curDepth);
 
diff -r c8ec86965e54 -r a2acf2e18b32 source/encoder/entropy.h
--- a/source/encoder/entropy.h	Fri Feb 19 14:36:52 2016 +0530
+++ b/source/encoder/entropy.h	Fri Mar 25 10:27:34 2016 +0900
@@ -162,7 +162,6 @@
 
     void codePartSize(const CUData& cu, uint32_t absPartIdx, uint32_t depth);
     void codePredInfo(const CUData& cu, uint32_t absPartIdx);
-    inline void codeQtCbfLuma(const CUData& cu, uint32_t absPartIdx, uint32_t tuDepth) { codeQtCbfLuma(cu.getCbf(absPartIdx, TEXT_LUMA, tuDepth), tuDepth); }
 
     void codeQtCbfChroma(const CUData& cu, uint32_t absPartIdx, TextType ttype, uint32_t tuDepth, bool lowestLevel);
     void codeCoeff(const CUData& cu, uint32_t absPartIdx, bool& bCodeDQP, const uint32_t depthRange[2]);
diff -r c8ec86965e54 -r a2acf2e18b32 source/encoder/search.cpp
--- a/source/encoder/search.cpp	Fri Feb 19 14:36:52 2016 +0530
+++ b/source/encoder/search.cpp	Fri Mar 25 10:27:34 2016 +0900
@@ -222,9 +222,10 @@
 
     if (!(log2TrSize - m_hChromaShift < 2))
     {
-        if (!tuDepth || cu.getCbf(absPartIdx, TEXT_CHROMA_U, tuDepth - 1))
+        uint32_t parentIdx = absPartIdx & (0xFF << (log2TrSize + 1 - LOG2_UNIT_SIZE) * 2);
+        if (!tuDepth || cu.getCbf(parentIdx, TEXT_CHROMA_U, tuDepth - 1))
             m_entropyCoder.codeQtCbfChroma(cu, absPartIdx, TEXT_CHROMA_U, tuDepth, !subdiv);
-        if (!tuDepth || cu.getCbf(absPartIdx, TEXT_CHROMA_V, tuDepth - 1))
+        if (!tuDepth || cu.getCbf(parentIdx, TEXT_CHROMA_V, tuDepth - 1))
             m_entropyCoder.codeQtCbfChroma(cu, absPartIdx, TEXT_CHROMA_V, tuDepth, !subdiv);
     }
 
@@ -434,8 +435,7 @@
 
             cbf |= cu.getCbf(qPartIdx, TEXT_LUMA, tuDepth + 1);
         }
-        for (uint32_t offs = 0; offs < 4 * qNumParts; offs++)
-            cu.m_cbf[0][absPartIdx + offs] |= (cbf << tuDepth);
+        cu.m_cbf[0][absPartIdx] |= (cbf << tuDepth);
 
         if (mightNotSplit && log2TrSize != depthRange[0])
         {
@@ -718,8 +718,7 @@
             residualTransformQuantIntra(mode, cuGeom, qPartIdx, tuDepth + 1, depthRange);
             cbf |= cu.getCbf(qPartIdx, TEXT_LUMA, tuDepth + 1);
         }
-        for (uint32_t offs = 0; offs < 4 * qNumParts; offs++)
-            cu.m_cbf[0][absPartIdx + offs] |= (cbf << tuDepth);
+        cu.m_cbf[0][absPartIdx] |= (cbf << tuDepth);
     }
 }
 
@@ -795,11 +794,9 @@
             splitCbfU |= cu.getCbf(qPartIdx, TEXT_CHROMA_U, tuDepth + 1);
             splitCbfV |= cu.getCbf(qPartIdx, TEXT_CHROMA_V, tuDepth + 1);
         }
-        for (uint32_t offs = 0; offs < 4 * qNumParts; offs++)
-        {
-            cu.m_cbf[1][absPartIdx + offs] |= (splitCbfU << tuDepth);
-            cu.m_cbf[2][absPartIdx + offs] |= (splitCbfV << tuDepth);
-        }
+        cu.m_cbf[1][absPartIdx] |= (splitCbfU << tuDepth);
+        cu.m_cbf[2][absPartIdx] |= (splitCbfV << tuDepth);
+
         return;
     }
 
@@ -1093,11 +1090,8 @@
             splitCbfU |= cu.getCbf(qPartIdx, TEXT_CHROMA_U, tuDepth + 1);
             splitCbfV |= cu.getCbf(qPartIdx, TEXT_CHROMA_V, tuDepth + 1);
         }
-        for (uint32_t offs = 0; offs < 4 * qNumParts; offs++)
-        {
-            cu.m_cbf[1][absPartIdx + offs] |= (splitCbfU << tuDepth);
-            cu.m_cbf[2][absPartIdx + offs] |= (splitCbfV << tuDepth);
-        }
+        cu.m_cbf[1][absPartIdx] |= (splitCbfU << tuDepth);
+        cu.m_cbf[2][absPartIdx] |= (splitCbfV << tuDepth);
 
         return;
     }
@@ -1631,8 +1625,7 @@
         for (uint32_t qIdx = 0, qPartIdx = 0; qIdx < 4; ++qIdx, qPartIdx += qNumParts)
             combCbfY |= cu.getCbf(qPartIdx, TEXT_LUMA, 1);
 
-        for (uint32_t offs = 0; offs < 4 * qNumParts; offs++)
-            cu.m_cbf[0][offs] |= combCbfY;
+        cu.m_cbf[0][0] |= combCbfY;
     }
 
     // TODO: remove this
@@ -1818,11 +1811,8 @@
             combCbfV |= cu.getCbf(qPartIdx, TEXT_CHROMA_V, 1);
         }
 
-        for (uint32_t offs = 0; offs < 4 * qNumParts; offs++)
-        {
-            cu.m_cbf[1][offs] |= combCbfU;
-            cu.m_cbf[2][offs] |= combCbfV;
-        }
+        cu.m_cbf[1][0] |= combCbfU;
+        cu.m_cbf[2][0] |= combCbfV;
     }
 
     /* TODO: remove this */
@@ -2818,14 +2808,11 @@
                 vcbf |= cu.getCbf(qPartIdx, TEXT_CHROMA_V, tuDepth + 1);
             }
         }
-        for (uint32_t i = 0; i < 4 * qNumParts; ++i)
+        cu.m_cbf[0][absPartIdx] |= ycbf << tuDepth;
+        if (m_csp != X265_CSP_I400)
         {
-            cu.m_cbf[0][absPartIdx + i] |= ycbf << tuDepth;
-            if (m_csp != X265_CSP_I400)
-            {
-                cu.m_cbf[1][absPartIdx + i] |= ucbf << tuDepth;
-                cu.m_cbf[2][absPartIdx + i] |= vcbf << tuDepth;
-            }
+            cu.m_cbf[1][absPartIdx] |= ucbf << tuDepth;
+            cu.m_cbf[2][absPartIdx] |= vcbf << tuDepth;
         }
     }
 }
@@ -3323,14 +3310,11 @@
                 vcbf |= cu.getCbf(qPartIdx, TEXT_CHROMA_V, tuDepth + 1);
             }
         }
-        for (uint32_t i = 0; i < 4 * qNumParts; ++i)
+        cu.m_cbf[0][absPartIdx] |= ycbf << tuDepth;
+        if (m_csp != X265_CSP_I400)
         {
-            cu.m_cbf[0][absPartIdx + i] |= ycbf << tuDepth;
-            if (m_csp != X265_CSP_I400)
-            {
-                cu.m_cbf[1][absPartIdx + i] |= ucbf << tuDepth;
-                cu.m_cbf[2][absPartIdx + i] |= vcbf << tuDepth;
-            }
+            cu.m_cbf[1][absPartIdx] |= ucbf << tuDepth;
+            cu.m_cbf[2][absPartIdx] |= vcbf << tuDepth;
         }
 
         // Here we were encoding cbfs and coefficients for splitted blocks. Since I have collected coefficient bits
@@ -3423,21 +3407,17 @@
     {
         if (!(log2TrSize - m_hChromaShift < 2))
         {
-            if (!tuDepth || cu.getCbf(absPartIdx, TEXT_CHROMA_U, tuDepth - 1))
+            uint32_t parentIdx = absPartIdx & (0xFF << (log2TrSize + 1 - LOG2_UNIT_SIZE) * 2);
+            if (!tuDepth || cu.getCbf(parentIdx, TEXT_CHROMA_U, tuDepth - 1))
                 m_entropyCoder.codeQtCbfChroma(cu, absPartIdx, TEXT_CHROMA_U, tuDepth, !bSubdiv);
-            if (!tuDepth || cu.getCbf(absPartIdx, TEXT_CHROMA_V, tuDepth - 1))
+            if (!tuDepth || cu.getCbf(parentIdx, TEXT_CHROMA_V, tuDepth - 1))
                 m_entropyCoder.codeQtCbfChroma(cu, absPartIdx, TEXT_CHROMA_V, tuDepth, !bSubdiv);
         }
-        else
-        {
-            X265_CHECK(cu.getCbf(absPartIdx, TEXT_CHROMA_U, tuDepth) == cu.getCbf(absPartIdx, TEXT_CHROMA_U, tuDepth - 1), "chroma CBF not matching\n");
-            X265_CHECK(cu.getCbf(absPartIdx, TEXT_CHROMA_V, tuDepth) == cu.getCbf(absPartIdx, TEXT_CHROMA_V, tuDepth - 1), "chroma CBF not matching\n");
-        }
     }
 
     if (!bSubdiv)
     {
-        m_entropyCoder.codeQtCbfLuma(cu, absPartIdx, tuDepth);
+        m_entropyCoder.codeQtCbfLuma(cu.getCbf(absPartIdx, TEXT_LUMA, tuDepth), tuDepth);
     }
     else
     {


More information about the x265-devel mailing list