[x265] [PATCH] search: give each Search instance an Entropy encoder (no output changes)

Steve Borho steve at borho.org
Fri Sep 26 00:58:18 CEST 2014


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1411685864 18000
#      Thu Sep 25 17:57:44 2014 -0500
# Node ID 58e21257c7dfea75c8713f650020f0e239ffacf3
# Parent  9cc2a85e1f07c12442fc689015f27295bfebd6a8
search: give each Search instance an Entropy encoder (no output changes)

This essentially relocates the "active" entropy coder used during all analysis
from CTURow to ThreadLocalData. This actually reduces the number of Entropy
instances in the encoder, and solves the problem of sharing the entropy coder
between worker threads cooperating on the same CTU.

diff -r 9cc2a85e1f07 -r 58e21257c7df source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp	Thu Sep 25 15:09:01 2014 -0500
+++ b/source/encoder/analysis.cpp	Thu Sep 25 17:57:44 2014 -0500
@@ -447,9 +447,9 @@
         }
         else
         {
-            m_entropyCoder->resetBits();
-            m_entropyCoder->codeSplitFlag(outBestCU, 0, depth);
-            outBestCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits
+            m_entropyCoder.resetBits();
+            m_entropyCoder.codeSplitFlag(outBestCU, 0, depth);
+            outBestCU->m_totalBits += m_entropyCoder.getNumberOfWrittenBits(); // split bits
         }
         if (m_rdCost.m_psyRd)
             outBestCU->m_totalPsyCost = m_rdCost.calcPsyRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits, outBestCU->m_psyEnergy);
@@ -492,9 +492,9 @@
         }
         if (cu_unsplit_flag)
         {
-            m_entropyCoder->resetBits();
-            m_entropyCoder->codeSplitFlag(outTempCU, 0, depth);
-            outTempCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits
+            m_entropyCoder.resetBits();
+            m_entropyCoder.codeSplitFlag(outTempCU, 0, depth);
+            outTempCU->m_totalBits += m_entropyCoder.getNumberOfWrittenBits(); // split bits
         }
 
         if (m_rdCost.m_psyRd)
@@ -579,9 +579,9 @@
 
         if (!(depth == g_maxCUDepth))
         {
-            m_entropyCoder->resetBits();
-            m_entropyCoder->codeSplitFlag(outBestCU, 0, depth);
-            outBestCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits();
+            m_entropyCoder.resetBits();
+            m_entropyCoder.codeSplitFlag(outBestCU, 0, depth);
+            outBestCU->m_totalBits += m_entropyCoder.getNumberOfWrittenBits();
         }
 
         // set current best CU cost to 0 marking as best CU present in shared CU data
@@ -639,9 +639,9 @@
 
         if (cu_unsplit_flag)
         {
-            m_entropyCoder->resetBits();
-            m_entropyCoder->codeSplitFlag(outTempCU, 0, depth);
-            outTempCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits
+            m_entropyCoder.resetBits();
+            m_entropyCoder.codeSplitFlag(outTempCU, 0, depth);
+            outTempCU->m_totalBits += m_entropyCoder.getNumberOfWrittenBits(); // split bits
         }
         if (depth == slice->m_pps->maxCuDQPDepth && slice->m_pps->bUseDQP)
         {
@@ -706,19 +706,19 @@
 
     estIntraPredChromaQT(outTempCU, m_origYuv[depth], m_tmpPredYuv[depth], m_tmpResiYuv[depth], m_tmpRecoYuv[depth]);
 
-    m_entropyCoder->resetBits();
+    m_entropyCoder.resetBits();
     if (outTempCU->m_slice->m_pps->bTransquantBypassEnabled)
-        m_entropyCoder->codeCUTransquantBypassFlag(outTempCU->getCUTransquantBypass(0));
+        m_entropyCoder.codeCUTransquantBypassFlag(outTempCU->getCUTransquantBypass(0));
 
-    m_entropyCoder->codePartSize(outTempCU, 0, depth);
-    m_entropyCoder->codePredInfo(outTempCU, 0);
-    outTempCU->m_mvBits = m_entropyCoder->getNumberOfWrittenBits();
+    m_entropyCoder.codePartSize(outTempCU, 0, depth);
+    m_entropyCoder.codePredInfo(outTempCU, 0);
+    outTempCU->m_mvBits = m_entropyCoder.getNumberOfWrittenBits();
 
     // Encode Coefficients
     bool bCodeDQP = m_bEncodeDQP;
-    m_entropyCoder->codeCoeff(outTempCU, 0, depth, bCodeDQP, tuDepthRange);
-    m_entropyCoder->store(m_rdEntropyCoders[depth][CI_TEMP_BEST]);
-    outTempCU->m_totalBits = m_entropyCoder->getNumberOfWrittenBits();
+    m_entropyCoder.codeCoeff(outTempCU, 0, depth, bCodeDQP, tuDepthRange);
+    m_entropyCoder.store(m_rdEntropyCoders[depth][CI_TEMP_BEST]);
+    outTempCU->m_totalBits = m_entropyCoder.getNumberOfWrittenBits();
     outTempCU->m_coeffBits = outTempCU->m_totalBits - outTempCU->m_mvBits;
 
     /* TODO: add chroma psyEnergy also to psyCost */
@@ -996,9 +996,9 @@
             {
                 if (depth < g_maxCUDepth)
                 {
-                    m_entropyCoder->resetBits();
-                    m_entropyCoder->codeSplitFlag(outBestCU, 0, depth);
-                    outBestCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits
+                    m_entropyCoder.resetBits();
+                    m_entropyCoder.codeSplitFlag(outBestCU, 0, depth);
+                    outBestCU->m_totalBits += m_entropyCoder.getNumberOfWrittenBits(); // split bits
                 }
                 if (m_rdCost.m_psyRd)
                     outBestCU->m_totalPsyCost = m_rdCost.calcPsyRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits, outBestCU->m_psyEnergy);
@@ -1120,9 +1120,9 @@
         {
             if (m_param->rdLevel > 1)
             {
-                m_entropyCoder->resetBits();
-                m_entropyCoder->codeSplitFlag(outTempCU, 0, depth);
-                outTempCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits
+                m_entropyCoder.resetBits();
+                m_entropyCoder.codeSplitFlag(outTempCU, 0, depth);
+                outTempCU->m_totalBits += m_entropyCoder.getNumberOfWrittenBits(); // split bits
             }
         }
         if (m_param->rdLevel > 1)
@@ -1413,9 +1413,9 @@
 
         if (depth < g_maxCUDepth)
         {
-            m_entropyCoder->resetBits();
-            m_entropyCoder->codeSplitFlag(outBestCU, 0, depth);
-            outBestCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits
+            m_entropyCoder.resetBits();
+            m_entropyCoder.codeSplitFlag(outBestCU, 0, depth);
+            outBestCU->m_totalBits += m_entropyCoder.getNumberOfWrittenBits(); // split bits
         }
         if (m_rdCost.m_psyRd)
             outBestCU->m_totalPsyCost = m_rdCost.calcPsyRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits, outBestCU->m_psyEnergy);
@@ -1462,9 +1462,9 @@
 
         if (cu_unsplit_flag)
         {
-            m_entropyCoder->resetBits();
-            m_entropyCoder->codeSplitFlag(outTempCU, 0, depth);
-            outTempCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits
+            m_entropyCoder.resetBits();
+            m_entropyCoder.codeSplitFlag(outTempCU, 0, depth);
+            outTempCU->m_totalBits += m_entropyCoder.getNumberOfWrittenBits(); // split bits
         }
 
         if (m_rdCost.m_psyRd)
@@ -1954,24 +1954,24 @@
 
     estIntraPredChromaQT(outTempCU, m_origYuv[depth], m_tmpPredYuv[depth], m_tmpResiYuv[depth], m_tmpRecoYuv[depth]);
 
-    m_entropyCoder->resetBits();
+    m_entropyCoder.resetBits();
     if (outTempCU->m_slice->m_pps->bTransquantBypassEnabled)
-        m_entropyCoder->codeCUTransquantBypassFlag(outTempCU->getCUTransquantBypass(0));
+        m_entropyCoder.codeCUTransquantBypassFlag(outTempCU->getCUTransquantBypass(0));
 
     if (!outTempCU->m_slice->isIntra())
     {
-        m_entropyCoder->codeSkipFlag(outTempCU, 0);
-        m_entropyCoder->codePredMode(outTempCU->getPredictionMode(0));
+        m_entropyCoder.codeSkipFlag(outTempCU, 0);
+        m_entropyCoder.codePredMode(outTempCU->getPredictionMode(0));
     }
-    m_entropyCoder->codePartSize(outTempCU, 0, depth);
-    m_entropyCoder->codePredInfo(outTempCU, 0);
-    outTempCU->m_mvBits = m_entropyCoder->getNumberOfWrittenBits();
+    m_entropyCoder.codePartSize(outTempCU, 0, depth);
+    m_entropyCoder.codePredInfo(outTempCU, 0);
+    outTempCU->m_mvBits = m_entropyCoder.getNumberOfWrittenBits();
 
     // Encode Coefficients
     bool bCodeDQP = m_bEncodeDQP;
-    m_entropyCoder->codeCoeff(outTempCU, 0, depth, bCodeDQP, tuDepthRange);
-    m_entropyCoder->store(m_rdEntropyCoders[depth][CI_TEMP_BEST]);
-    outTempCU->m_totalBits = m_entropyCoder->getNumberOfWrittenBits();
+    m_entropyCoder.codeCoeff(outTempCU, 0, depth, bCodeDQP, tuDepthRange);
+    m_entropyCoder.store(m_rdEntropyCoders[depth][CI_TEMP_BEST]);
+    outTempCU->m_totalBits = m_entropyCoder.getNumberOfWrittenBits();
     outTempCU->m_coeffBits = outTempCU->m_totalBits - outTempCU->m_mvBits;
 
     if (m_rdCost.m_psyRd)
@@ -1997,7 +1997,7 @@
     uint32_t initTrDepth = cu->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1;
 
     // set context models
-    m_entropyCoder->load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
+    m_entropyCoder.load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
 
     m_quant.setQPforQuant(cu);
 
@@ -2014,25 +2014,25 @@
     cu->m_totalDistortion = puDistY;
 
     estIntraPredChromaQT(cu, fencYuv, predYuv, outResiYuv, outReconYuv);
-    m_entropyCoder->resetBits();
+    m_entropyCoder.resetBits();
     if (cu->m_slice->m_pps->bTransquantBypassEnabled)
-        m_entropyCoder->codeCUTransquantBypassFlag(cu->getCUTransquantBypass(0));
+        m_entropyCoder.codeCUTransquantBypassFlag(cu->getCUTransquantBypass(0));
 
     if (!cu->m_slice->isIntra())
     {
-        m_entropyCoder->codeSkipFlag(cu, 0);
-        m_entropyCoder->codePredMode(cu->getPredictionMode(0));
+        m_entropyCoder.codeSkipFlag(cu, 0);
+        m_entropyCoder.codePredMode(cu->getPredictionMode(0));
     }
-    m_entropyCoder->codePartSize(cu, 0, depth);
-    m_entropyCoder->codePredInfo(cu, 0);
-    cu->m_mvBits += m_entropyCoder->getNumberOfWrittenBits();
+    m_entropyCoder.codePartSize(cu, 0, depth);
+    m_entropyCoder.codePredInfo(cu, 0);
+    cu->m_mvBits += m_entropyCoder.getNumberOfWrittenBits();
 
     // Encode Coefficients
     bool bCodeDQP = m_bEncodeDQP;
-    m_entropyCoder->codeCoeff(cu, 0, depth, bCodeDQP, tuDepthRange);
-    m_entropyCoder->store(m_rdEntropyCoders[depth][CI_TEMP_BEST]);
+    m_entropyCoder.codeCoeff(cu, 0, depth, bCodeDQP, tuDepthRange);
+    m_entropyCoder.store(m_rdEntropyCoders[depth][CI_TEMP_BEST]);
 
-    cu->m_totalBits = m_entropyCoder->getNumberOfWrittenBits();
+    cu->m_totalBits = m_entropyCoder.getNumberOfWrittenBits();
     cu->m_coeffBits = cu->m_totalBits - cu->m_mvBits;
     if (m_rdCost.m_psyRd)
     {
diff -r 9cc2a85e1f07 -r 58e21257c7df source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Thu Sep 25 15:09:01 2014 -0500
+++ b/source/encoder/frameencoder.cpp	Thu Sep 25 17:57:44 2014 -0500
@@ -630,8 +630,6 @@
     tld.analysis.m_me.setSourcePlane(fenc->getLumaAddr(), fenc->getStride());
     tld.analysis.m_log = &tld.analysis.m_sliceTypeLog[m_frame->m_picSym->m_slice->m_sliceType];
     tld.analysis.m_rdEntropyCoders = curRow.rdEntropyCoders;
-    tld.analysis.m_entropyCoder = &curRow.entropyCoder;
-    tld.analysis.m_quant.m_entropyCoder = &curRow.entropyCoder;
     setLambda(m_frame->m_picSym->m_slice->m_sliceQp, tld);
 
     int64_t startTime = x265_mdate();
diff -r 9cc2a85e1f07 -r 58e21257c7df source/encoder/frameencoder.h
--- a/source/encoder/frameencoder.h	Thu Sep 25 15:09:01 2014 -0500
+++ b/source/encoder/frameencoder.h	Thu Sep 25 17:57:44 2014 -0500
@@ -60,7 +60,6 @@
  * WPP is active, several rows will be simultaneously encoded. */
 struct CTURow
 {
-    Entropy           entropyCoder;
     Entropy           bufferEntropyCoder;  /* store context for next row */
     Entropy           rdEntropyCoders[NUM_FULL_DEPTH][CI_NUM];
 
@@ -93,8 +92,6 @@
         completed = 0;
         memset(&rowStats, 0, sizeof(rowStats));
 
-        entropyCoder.load(initContext);
-
         for (uint32_t depth = 0; depth <= g_maxFullDepth; depth++)
             for (int ciIdx = 0; ciIdx < CI_NUM; ciIdx++)
                 rdEntropyCoders[depth][ciIdx].load(initContext);
diff -r 9cc2a85e1f07 -r 58e21257c7df source/encoder/search.cpp
--- a/source/encoder/search.cpp	Thu Sep 25 15:09:01 2014 -0500
+++ b/source/encoder/search.cpp	Thu Sep 25 17:57:44 2014 -0500
@@ -47,7 +47,6 @@
 
     m_numLayers = 0;
     m_param = NULL;
-    m_entropyCoder = NULL;
     m_rdEntropyCoders = NULL;
 }
 
@@ -74,6 +73,7 @@
     m_numLayers = g_log2Size[param->maxCUSize] - 2;
 
     bool ok = m_quant.init(m_bEnableRDOQ, param->psyRdoq, scalingList);
+    m_quant.m_entropyCoder = &m_entropyCoder; /* TODO: move to Quant::init() */
 
     m_rdCost.setPsyRdScale(param->psyRd);
 
@@ -123,11 +123,11 @@
 
     if ((log2TrSize > 2) && !(m_csp == X265_CSP_I444))
     {
-        if (trDepth == 0 || cu->getCbf(absPartIdx, TEXT_CHROMA_U, trDepth - 1))
-            m_entropyCoder->codeQtCbf(cu, absPartIdx, absPartIdxStep, (width >> hChromaShift), (height >> vChromaShift), TEXT_CHROMA_U, trDepth, (subdiv == 0));
-
-        if (trDepth == 0 || cu->getCbf(absPartIdx, TEXT_CHROMA_V, trDepth - 1))
-            m_entropyCoder->codeQtCbf(cu, absPartIdx, absPartIdxStep, (width >> hChromaShift), (height >> vChromaShift), TEXT_CHROMA_V, trDepth, (subdiv == 0));
+        if (!trDepth || cu->getCbf(absPartIdx, TEXT_CHROMA_U, trDepth - 1))
+            m_entropyCoder.codeQtCbf(cu, absPartIdx, absPartIdxStep, (width >> hChromaShift), (height >> vChromaShift), TEXT_CHROMA_U, trDepth, !subdiv);
+
+        if (!trDepth || cu->getCbf(absPartIdx, TEXT_CHROMA_V, trDepth - 1))
+            m_entropyCoder.codeQtCbf(cu, absPartIdx, absPartIdxStep, (width >> hChromaShift), (height >> vChromaShift), TEXT_CHROMA_V, trDepth, !subdiv);
     }
 
     if (subdiv)
@@ -183,7 +183,7 @@
         uint32_t shift = (m_csp == X265_CSP_I420) ? 2 : 0;
         uint32_t coeffOffset = absPartIdx << (LOG2_UNIT_SIZE * 2 - shift);
         coeff_t* coeff = m_qtTempCoeff[ttype][qtLayer] + coeffOffset;
-        m_entropyCoder->codeCoeffNxN(cu, coeff, absPartIdx, log2TrSizeC, ttype);
+        m_entropyCoder.codeCoeffNxN(cu, coeff, absPartIdx, log2TrSizeC, ttype);
     }
     else
     {
@@ -192,9 +192,9 @@
         uint32_t subTUSize = 1 << (log2TrSizeC * 2);
         uint32_t partIdxesPerSubTU  = NUM_CU_PARTITIONS >> (((cu->getDepth(absPartIdx) + trDepthC) << 1) + 1);
         if (cu->getCbf(absPartIdx, ttype, trDepth + 1))
-            m_entropyCoder->codeCoeffNxN(cu, coeff, absPartIdx, log2TrSizeC, ttype);
+            m_entropyCoder.codeCoeffNxN(cu, coeff, absPartIdx, log2TrSizeC, ttype);
         if (cu->getCbf(absPartIdx + partIdxesPerSubTU, ttype, trDepth + 1))
-            m_entropyCoder->codeCoeffNxN(cu, coeff + subTUSize, absPartIdx + partIdxesPerSubTU, log2TrSizeC, ttype);
+            m_entropyCoder.codeCoeffNxN(cu, coeff + subTUSize, absPartIdx + partIdxesPerSubTU, log2TrSizeC, ttype);
     }
 }
 
@@ -206,18 +206,18 @@
         if (!cu->m_slice->isIntra())
         {
             if (cu->m_slice->m_pps->bTransquantBypassEnabled)
-                m_entropyCoder->codeCUTransquantBypassFlag(cu->getCUTransquantBypass(0));
-            m_entropyCoder->codeSkipFlag(cu, 0);
-            m_entropyCoder->codePredMode(cu->getPredictionMode(0));
+                m_entropyCoder.codeCUTransquantBypassFlag(cu->getCUTransquantBypass(0));
+            m_entropyCoder.codeSkipFlag(cu, 0);
+            m_entropyCoder.codePredMode(cu->getPredictionMode(0));
         }
 
-        m_entropyCoder->codePartSize(cu, 0, cu->getDepth(0));
+        m_entropyCoder.codePartSize(cu, 0, cu->getDepth(0));
     }
     // luma prediction mode
     if (cu->getPartitionSize(0) == SIZE_2Nx2N)
     {
         if (!absPartIdx)
-            m_entropyCoder->codeIntraDirLumaAng(cu, 0, false);
+            m_entropyCoder.codeIntraDirLumaAng(cu, 0, false);
     }
     else
     {
@@ -226,10 +226,10 @@
         {
             X265_CHECK(absPartIdx == 0, "unexpected absPartIdx %d\n", absPartIdx);
             for (uint32_t part = 0; part < 4; part++)
-                m_entropyCoder->codeIntraDirLumaAng(cu, part * qtNumParts, false);
+                m_entropyCoder.codeIntraDirLumaAng(cu, part * qtNumParts, false);
         }
         else if (!(absPartIdx & (qtNumParts - 1)))
-            m_entropyCoder->codeIntraDirLumaAng(cu, absPartIdx, false);
+            m_entropyCoder.codeIntraDirLumaAng(cu, absPartIdx, false);
     }
 }
 
@@ -239,51 +239,51 @@
     if (cu->getPartitionSize(0) == SIZE_2Nx2N || cu->getChromaFormat() != X265_CSP_I444)
     {
         if (!absPartIdx)
-            m_entropyCoder->codeIntraDirChroma(cu, absPartIdx);
+            m_entropyCoder.codeIntraDirChroma(cu, absPartIdx);
     }
     else
     {
         uint32_t qtNumParts = cu->getTotalNumPart() >> 2;
         if (!(absPartIdx & (qtNumParts - 1)))
-            m_entropyCoder->codeIntraDirChroma(cu, absPartIdx);
+            m_entropyCoder.codeIntraDirChroma(cu, absPartIdx);
     }
 }
 
 uint32_t Search::xGetIntraBitsQTChroma(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, uint32_t absPartIdxStep)
 {
     int cuSize = 1 << cu->getLog2CUSize(absPartIdx);
-    m_entropyCoder->resetBits();
+    m_entropyCoder.resetBits();
     xEncIntraHeaderChroma(cu, absPartIdx);
     xEncSubdivCbfQTChroma(cu, trDepth, absPartIdx, absPartIdxStep, cuSize, cuSize);
     xEncCoeffQTChroma(cu, trDepth, absPartIdx, TEXT_CHROMA_U);
     xEncCoeffQTChroma(cu, trDepth, absPartIdx, TEXT_CHROMA_V);
-    return m_entropyCoder->getNumberOfWrittenBits();
+    return m_entropyCoder.getNumberOfWrittenBits();
 }
 
 uint32_t Search::xGetIntraBitsLuma(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, uint32_t log2TrSize, coeff_t* coeff, uint32_t depthRange[2])
 {
-    m_entropyCoder->resetBits();
+    m_entropyCoder.resetBits();
     xEncIntraHeaderLuma(cu, trDepth, absPartIdx);
 
     // Transform subdiv flag
     if (log2TrSize != *depthRange)
-        m_entropyCoder->codeTransformSubdivFlag(0, 5 - log2TrSize);
+        m_entropyCoder.codeTransformSubdivFlag(0, 5 - log2TrSize);
 
     // Cbfs
     uint32_t trMode = cu->getTransformIdx(absPartIdx);
-    m_entropyCoder->codeQtCbf(cu, absPartIdx, TEXT_LUMA, trMode);
+    m_entropyCoder.codeQtCbf(cu, absPartIdx, TEXT_LUMA, trMode);
 
     if (cu->getCbf(absPartIdx, TEXT_LUMA, trDepth))
-        m_entropyCoder->codeCoeffNxN(cu, coeff, absPartIdx, log2TrSize, TEXT_LUMA);
-
-    return m_entropyCoder->getNumberOfWrittenBits();
+        m_entropyCoder.codeCoeffNxN(cu, coeff, absPartIdx, log2TrSize, TEXT_LUMA);
+
+    return m_entropyCoder.getNumberOfWrittenBits();
 }
 
 uint32_t Search::xGetIntraBitsChroma(TComDataCU* cu, uint32_t absPartIdx, uint32_t log2TrSizeC, uint32_t chromaId, coeff_t* coeff)
 {
-    m_entropyCoder->resetBits();
-    m_entropyCoder->codeCoeffNxN(cu, coeff, absPartIdx, log2TrSizeC, (TextType)chromaId);
-    return m_entropyCoder->getNumberOfWrittenBits();
+    m_entropyCoder.resetBits();
+    m_entropyCoder.codeCoeffNxN(cu, coeff, absPartIdx, log2TrSizeC, (TextType)chromaId);
+    return m_entropyCoder.getNumberOfWrittenBits();
 }
 
 /* returns distortion */
@@ -313,7 +313,7 @@
 
     // transform and quantization
     if (m_bEnableRDOQ)
-        m_entropyCoder->estBit(m_entropyCoder->m_estBitsSbac, log2TrSize, true);
+        m_entropyCoder.estBit(m_entropyCoder.m_estBitsSbac, log2TrSize, true);
 
     uint32_t numSig = m_quant.transformNxN(cu, fenc, stride, residual, stride, coeff, log2TrSize, TEXT_LUMA, absPartIdx, useTransformSkip);
     if (numSig)
@@ -364,7 +364,7 @@
 
     // init rate estimation arrays for RDOQ
     if (m_bEnableRDOQ)
-        m_entropyCoder->estBit(m_entropyCoder->m_estBitsSbac, log2TrSizeC, false);
+        m_entropyCoder.estBit(m_entropyCoder.m_estBitsSbac, log2TrSizeC, false);
 
     uint32_t numSig = m_quant.transformNxN(cu, fenc, stride, residual, stride, coeff, log2TrSizeC, ttype, absPartIdx, useTransformSkipC);
 
@@ -471,7 +471,7 @@
         if (checkTransformSkip || checkTQbypass)
         {
             // store original entropy coding status
-            m_entropyCoder->store(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+            m_entropyCoder.store(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 
             uint32_t  singleDistYTmp = 0;
             uint32_t  singlePsyEnergyYTmp = 0;
@@ -528,10 +528,10 @@
                     bestTQbypass = singleTQbypass;
                     bestModeId   = modeId;
                     if (bestModeId == firstCheckId)
-                        m_entropyCoder->store(m_rdEntropyCoders[fullDepth][CI_TEMP_BEST]);
+                        m_entropyCoder.store(m_rdEntropyCoders[fullDepth][CI_TEMP_BEST]);
                 }
                 if (modeId == firstCheckId)
-                    m_entropyCoder->load(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+                    m_entropyCoder.load(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_ROOT]);
             }
 
             cu->setTransformSkipSubParts(checkTransformSkip ? bestModeId : 0, TEXT_LUMA, absPartIdx, fullDepth);
@@ -542,7 +542,7 @@
             {
                 xLoadIntraResultQT(cu, absPartIdx, log2TrSize, reconQt, reconQtStride);
                 cu->setCbfSubParts(singleCbfY << trDepth, TEXT_LUMA, absPartIdx, fullDepth);
-                m_entropyCoder->load(m_rdEntropyCoders[fullDepth][CI_TEMP_BEST]);
+                m_entropyCoder.load(m_rdEntropyCoders[fullDepth][CI_TEMP_BEST]);
             }
             else
             {
@@ -553,7 +553,7 @@
         }
         else
         {
-            m_entropyCoder->store(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+            m_entropyCoder.store(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 
             // code luma block with given intra prediction mode and store Cbf
             cu->setTransformSkipSubParts(0, TEXT_LUMA, absPartIdx, fullDepth);
@@ -582,11 +582,11 @@
         // store full entropy coding status, load original entropy coding status
         if (bCheckFull)
         {
-            m_entropyCoder->store(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_TEST]);
-            m_entropyCoder->load(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+            m_entropyCoder.store(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_TEST]);
+            m_entropyCoder.load(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_ROOT]);
         }
         else
-            m_entropyCoder->store(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+            m_entropyCoder.store(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 
         // code splitted block
         uint64_t splitCost     = 0;
@@ -606,9 +606,9 @@
 
         if (bCheckFull && log2TrSize != depthRange[0])
         {
-            m_entropyCoder->resetBits();
-            m_entropyCoder->codeTransformSubdivFlag(1, 5 - log2TrSize);
-            splitBits += m_entropyCoder->getNumberOfWrittenBits();
+            m_entropyCoder.resetBits();
+            m_entropyCoder.codeTransformSubdivFlag(1, 5 - log2TrSize);
+            splitBits += m_entropyCoder.getNumberOfWrittenBits();
         }
 
         for (uint32_t offs = 0; offs < 4 * qPartsDiv; offs++)
@@ -629,7 +629,7 @@
         }
 
         // set entropy coding status
-        m_entropyCoder->load(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_TEST]);
+        m_entropyCoder.load(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_TEST]);
 
         // set transform index and Cbf values
         cu->setTrIdxSubParts(trDepth, absPartIdx, fullDepth);
@@ -919,7 +919,7 @@
                 if (checkTransformSkip)
                 {
                     // use RDO to decide whether Cr/Cb takes TS
-                    m_entropyCoder->store(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+                    m_entropyCoder.store(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 
                     uint64_t singleCost     = MAX_INT64;
                     int      bestModeId     = 0;
@@ -969,17 +969,17 @@
                             singleCbfC  = singleCbfCTmp;
                             singlePsyEnergy = singlePsyEnergyTmp;
                             if (bestModeId == firstCheckId)
-                                m_entropyCoder->store(m_rdEntropyCoders[fullDepth][CI_TEMP_BEST]);
+                                m_entropyCoder.store(m_rdEntropyCoders[fullDepth][CI_TEMP_BEST]);
                         }
                         if (chromaModeId == firstCheckId)
-                            m_entropyCoder->load(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+                            m_entropyCoder.load(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_ROOT]);
                     }
 
                     if (bestModeId == firstCheckId)
                     {
                         xLoadIntraResultChromaQT(cu, absPartIdxC, log2TrSizeC, chromaId, reconQt, reconQtStride);
                         cu->setCbfPartRange(singleCbfC << trDepth, (TextType)chromaId, absPartIdxC, tuIterator.absPartIdxStep);
-                        m_entropyCoder->load(m_rdEntropyCoders[fullDepth][CI_TEMP_BEST]);
+                        m_entropyCoder.load(m_rdEntropyCoders[fullDepth][CI_TEMP_BEST]);
                     }
                     else
                     {
@@ -993,7 +993,7 @@
                     outDist += singleDistC;
 
                     if (chromaId == 1)
-                        m_entropyCoder->store(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+                        m_entropyCoder.store(m_rdEntropyCoders[fullDepth][CI_QT_TRAFO_ROOT]);
                 }
                 else
                 {
@@ -1342,7 +1342,7 @@
         {
             if (candCostList[i] == MAX_INT64)
                 break;
-            m_entropyCoder->load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
+            m_entropyCoder.load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
             cu->setLumaIntraDirSubParts(rdModeList[i], partOffset, depth + initTrDepth);
             cost = bits = 0;
             uint32_t psyEnergy = 0;
@@ -1352,7 +1352,7 @@
 
         /* remeasure best mode, allowing TU splits */
         cu->setLumaIntraDirSubParts(bmode, partOffset, depth + initTrDepth);
-        m_entropyCoder->load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
+        m_entropyCoder.load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
 
         uint32_t psyEnergy = 0;
         // update distortion (rate and r-d costs are determined later)
@@ -1382,7 +1382,7 @@
     }
 
     // reset context models
-    m_entropyCoder->load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
+    m_entropyCoder.load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
 
     x265_emms();
 }
@@ -1407,7 +1407,7 @@
         cu->setLumaIntraDirSubParts(sharedModes[pu], partOffset, depth + initTrDepth);
 
         // set context models
-        m_entropyCoder->load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
+        m_entropyCoder.load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
 
         uint32_t psyEnergy = 0;
         // update overall distortion (rate and r-d costs are determined later)
@@ -1440,7 +1440,7 @@
     }
 
     // reset context models
-    m_entropyCoder->load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
+    m_entropyCoder.load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
 }
 
 void Search::getBestIntraModeChroma(TComDataCU* cu, TComYuv* fencYuv, TComYuv* predYuv)
@@ -1526,7 +1526,7 @@
         for (uint32_t mode = minMode; mode < maxMode; mode++)
         {
             // restore context models
-            m_entropyCoder->load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
+            m_entropyCoder.load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
 
             // chroma coding
             cu->setChromIntraDirSubParts(modeList[mode], absPartIdxC, depth + initTrDepth);
@@ -1535,7 +1535,7 @@
             uint32_t dist = xRecurIntraChromaCodingQT(cu, initTrDepth, absPartIdxC, fencYuv, predYuv, resiYuv, psyEnergy);
 
             if (cu->m_slice->m_pps->bTransformSkipEnabled)
-                m_entropyCoder->load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
+                m_entropyCoder.load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
 
             uint32_t bits = xGetIntraBitsQTChroma(cu, initTrDepth, absPartIdxC, tuIterator.absPartIdxStep);
             uint64_t cost = 0; 
@@ -1601,7 +1601,7 @@
         }
     }
 
-    m_entropyCoder->load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
+    m_entropyCoder.load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
 }
 
 /* estimation of best merge coding */
@@ -2069,16 +2069,16 @@
     cu->m_totalDistortion += m_rdCost.scaleChromaDistCb(primitives.sse_pp[part](fencYuv->getCbAddr(), fencYuv->getCStride(), outReconYuv->getCbAddr(), outReconYuv->getCStride()));
     cu->m_totalDistortion += m_rdCost.scaleChromaDistCr(primitives.sse_pp[part](fencYuv->getCrAddr(), fencYuv->getCStride(), outReconYuv->getCrAddr(), outReconYuv->getCStride()));
 
-    m_entropyCoder->load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
-    m_entropyCoder->resetBits();
+    m_entropyCoder.load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
+    m_entropyCoder.resetBits();
     if (cu->m_slice->m_pps->bTransquantBypassEnabled)
-        m_entropyCoder->codeCUTransquantBypassFlag(cu->getCUTransquantBypass(0));
-    m_entropyCoder->codeSkipFlag(cu, 0);
-    m_entropyCoder->codeMergeIndex(cu, 0);
-
-    cu->m_mvBits = m_entropyCoder->getNumberOfWrittenBits();
+        m_entropyCoder.codeCUTransquantBypassFlag(cu->getCUTransquantBypass(0));
+    m_entropyCoder.codeSkipFlag(cu, 0);
+    m_entropyCoder.codeMergeIndex(cu, 0);
+
+    cu->m_mvBits = m_entropyCoder.getNumberOfWrittenBits();
     cu->m_coeffBits = 0;
-    cu->m_totalBits = m_entropyCoder->getNumberOfWrittenBits();
+    cu->m_totalBits = m_entropyCoder.getNumberOfWrittenBits();
 
     if (m_rdCost.m_psyRd)
     {
@@ -2090,7 +2090,7 @@
     else
         cu->m_totalRDCost = m_rdCost.calcRdCost(cu->m_totalDistortion, cu->m_totalBits);
 
-    m_entropyCoder->store(m_rdEntropyCoders[depth][CI_TEMP_BEST]);
+    m_entropyCoder.store(m_rdEntropyCoders[depth][CI_TEMP_BEST]);
 }
 
 /** encode residual and calculate rate-distortion for a CU block */
@@ -2133,21 +2133,21 @@
         bool bIsLosslessMode = bIsTQBypassEnable && !modeId;
 
         cu->setCUTransquantBypassSubParts(bIsLosslessMode, 0, depth);
-        m_entropyCoder->load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
+        m_entropyCoder.load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
 
         uint64_t cost = 0;
         uint32_t zeroDistortion = 0;
         uint32_t bits = 0;
         uint32_t distortion = xEstimateResidualQT(cu, 0, fencYuv, predYuv, outResiYuv, depth, cost, bits, &zeroDistortion, tuDepthRange);
 
-        m_entropyCoder->resetBits();
-        m_entropyCoder->codeQtRootCbfZero();
-        uint32_t zeroResiBits = m_entropyCoder->getNumberOfWrittenBits();
+        m_entropyCoder.resetBits();
+        m_entropyCoder.codeQtRootCbfZero();
+        uint32_t zeroResiBits = m_entropyCoder.getNumberOfWrittenBits();
         uint64_t zeroCost = 0;
         uint32_t zeroPsyEnergyY = 0;
         if (m_rdCost.m_psyRd)
         {
-            // need to check whether zero distortion is similar to psyenergy of fenc
+            // need to check whether zero distortion is similar to psy energy of fenc
             int size = log2CUSize - 2;
             zeroPsyEnergyY = m_rdCost.psyCost(size, fencYuv->getLumaAddr(), fencYuv->getStride(), (pixel*)zeroPel, 0);
             zeroCost = m_rdCost.calcPsyRdCost(zeroDistortion, zeroResiBits, zeroPsyEnergyY);
@@ -2178,7 +2178,7 @@
         else
             xSetResidualQTData(cu, 0, NULL, depth, false);
 
-        m_entropyCoder->load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
+        m_entropyCoder.load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
 
         bits = getInterSymbolBits(cu, tuDepthRange);
 
@@ -2196,7 +2196,7 @@
             bestBits = bits;
             bestCost = cost;
             bestCoeffBits = cu->m_coeffBits;
-            m_entropyCoder->store(m_rdEntropyCoders[depth][CI_TEMP_BEST]);
+            m_entropyCoder.store(m_rdEntropyCoders[depth][CI_TEMP_BEST]);
         }
     }
 
@@ -2205,12 +2205,12 @@
     if (bIsTQBypassEnable && !bestMode)
     {
         cu->setCUTransquantBypassSubParts(true, 0, depth);
-        m_entropyCoder->load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
+        m_entropyCoder.load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
         uint64_t cost = 0;
         uint32_t bits = 0;
         xEstimateResidualQT(cu, 0, fencYuv, predYuv, outResiYuv, depth, cost, bits, NULL, tuDepthRange);
         xSetResidualQTData(cu, 0, NULL, depth, false);
-        m_entropyCoder->store(m_rdEntropyCoders[depth][CI_TEMP_BEST]);
+        m_entropyCoder.store(m_rdEntropyCoders[depth][CI_TEMP_BEST]);
     }
 
     if (cu->getQtRootCbf(0))
@@ -2450,7 +2450,7 @@
 
     uint32_t bestCBF[MAX_NUM_COMPONENT];
     uint32_t bestsubTUCBF[MAX_NUM_COMPONENT][2];
-    m_entropyCoder->store(m_rdEntropyCoders[depth][CI_QT_TRAFO_ROOT]);
+    m_entropyCoder.store(m_rdEntropyCoders[depth][CI_QT_TRAFO_ROOT]);
 
     uint32_t trSize = 1 << log2TrSize;
     const bool splitIntoSubTUs = (m_csp == X265_CSP_I422);
@@ -2479,18 +2479,18 @@
         cu->setTransformSkipSubParts(0, TEXT_LUMA, absPartIdx, depth);
 
         if (m_bEnableRDOQ)
-            m_entropyCoder->estBit(m_entropyCoder->m_estBitsSbac, log2TrSize, true);
+            m_entropyCoder.estBit(m_entropyCoder.m_estBitsSbac, log2TrSize, true);
 
         numSigY = m_quant.transformNxN(cu, fencYuv->getLumaAddr(absPartIdx), fencYuv->getStride(), resiYuv->getLumaAddr(absPartIdx), resiYuv->m_width, coeffCurY,
                                        log2TrSize, TEXT_LUMA, absPartIdx, false);
 
         cu->setCbfSubParts(numSigY ? setCbf : 0, TEXT_LUMA, absPartIdx, depth);
 
-        m_entropyCoder->resetBits();
-        m_entropyCoder->codeQtCbf(cu, absPartIdx, TEXT_LUMA, trMode);
+        m_entropyCoder.resetBits();
+        m_entropyCoder.codeQtCbf(cu, absPartIdx, TEXT_LUMA, trMode);
         if (numSigY)
-            m_entropyCoder->codeCoeffNxN(cu, coeffCurY, absPartIdx, log2TrSize, TEXT_LUMA);
-        singleBitsComp[TEXT_LUMA][0] = m_entropyCoder->getNumberOfWrittenBits();
+            m_entropyCoder.codeCoeffNxN(cu, coeffCurY, absPartIdx, log2TrSize, TEXT_LUMA);
+        singleBitsComp[TEXT_LUMA][0] = m_entropyCoder.getNumberOfWrittenBits();
 
         uint32_t singleBitsPrev = singleBitsComp[TEXT_LUMA][0];
 
@@ -2507,7 +2507,7 @@
                 cu->setTransformSkipPartRange(0, TEXT_CHROMA_V, absPartIdxC, tuIterator.absPartIdxStep);
 
                 if (m_bEnableRDOQ)
-                    m_entropyCoder->estBit(m_entropyCoder->m_estBitsSbac, log2TrSizeC, false);
+                    m_entropyCoder.estBit(m_entropyCoder.m_estBitsSbac, log2TrSizeC, false);
 
                 numSigU[tuIterator.section] = m_quant.transformNxN(cu, fencYuv->getCbAddr(absPartIdxC), fencYuv->getCStride(), resiYuv->getCbAddr(absPartIdxC), resiYuv->m_cwidth, coeffCurU + subTUOffset,
                                                                    log2TrSizeC, TEXT_CHROMA_U, absPartIdxC, false);
@@ -2517,16 +2517,16 @@
                 cu->setCbfPartRange(numSigU[tuIterator.section] ? setCbf : 0, TEXT_CHROMA_U, absPartIdxC, tuIterator.absPartIdxStep);
                 cu->setCbfPartRange(numSigV[tuIterator.section] ? setCbf : 0, TEXT_CHROMA_V, absPartIdxC, tuIterator.absPartIdxStep);
 
-                m_entropyCoder->codeQtCbf(cu, absPartIdxC, TEXT_CHROMA_U, trMode);
+                m_entropyCoder.codeQtCbf(cu, absPartIdxC, TEXT_CHROMA_U, trMode);
                 if (numSigU[tuIterator.section])
-                    m_entropyCoder->codeCoeffNxN(cu, coeffCurU + subTUOffset, absPartIdxC, log2TrSizeC, TEXT_CHROMA_U);
-                singleBitsComp[TEXT_CHROMA_U][tuIterator.section] = m_entropyCoder->getNumberOfWrittenBits() - singleBitsPrev;
-
-                m_entropyCoder->codeQtCbf(cu, absPartIdxC, TEXT_CHROMA_V, trMode);
+                    m_entropyCoder.codeCoeffNxN(cu, coeffCurU + subTUOffset, absPartIdxC, log2TrSizeC, TEXT_CHROMA_U);
+                singleBitsComp[TEXT_CHROMA_U][tuIterator.section] = m_entropyCoder.getNumberOfWrittenBits() - singleBitsPrev;
+
+                m_entropyCoder.codeQtCbf(cu, absPartIdxC, TEXT_CHROMA_V, trMode);
                 if (numSigV[tuIterator.section])
-                    m_entropyCoder->codeCoeffNxN(cu, coeffCurV + subTUOffset, absPartIdxC, log2TrSizeC, TEXT_CHROMA_V);
-
-                uint32_t newBits = m_entropyCoder->getNumberOfWrittenBits();
+                    m_entropyCoder.codeCoeffNxN(cu, coeffCurV + subTUOffset, absPartIdxC, log2TrSizeC, TEXT_CHROMA_V);
+
+                uint32_t newBits = m_entropyCoder.getNumberOfWrittenBits();
                 singleBitsComp[TEXT_CHROMA_V][tuIterator.section] = newBits - (singleBitsPrev + singleBitsComp[TEXT_CHROMA_U][tuIterator.section]);
 
                 singleBitsPrev = newBits;
@@ -2593,9 +2593,9 @@
                     singleCostY = m_rdCost.calcPsyRdCost(nonZeroDistY, singleBitsComp[TEXT_LUMA][0], nonZeroPsyEnergyY);
                 else
                     singleCostY = m_rdCost.calcRdCost(nonZeroDistY, singleBitsComp[TEXT_LUMA][0]);
-                m_entropyCoder->resetBits();
-                m_entropyCoder->codeQtCbfZero(TEXT_LUMA, trMode);
-                const uint32_t nullBitsY = m_entropyCoder->getNumberOfWrittenBits();
+                m_entropyCoder.resetBits();
+                m_entropyCoder.codeQtCbfZero(TEXT_LUMA, trMode);
+                const uint32_t nullBitsY = m_entropyCoder.getNumberOfWrittenBits();
                 uint64_t nullCostY = 0;
                 if (m_rdCost.m_psyRd)
                     nullCostY = m_rdCost.calcPsyRdCost(distY, nullBitsY, psyEnergyY);
@@ -2621,9 +2621,9 @@
         }
         else if (checkTransformSkipY)
         {
-            m_entropyCoder->resetBits();
-            m_entropyCoder->codeQtCbfZero(TEXT_LUMA, trMode);
-            const uint32_t nullBitsY = m_entropyCoder->getNumberOfWrittenBits();
+            m_entropyCoder.resetBits();
+            m_entropyCoder.codeQtCbfZero(TEXT_LUMA, trMode);
+            const uint32_t nullBitsY = m_entropyCoder.getNumberOfWrittenBits();
             if (m_rdCost.m_psyRd)
                 minCost[TEXT_LUMA][0] = m_rdCost.calcPsyRdCost(distY, nullBitsY, psyEnergyY);
             else
@@ -2693,9 +2693,9 @@
                             singleCostU = m_rdCost.calcPsyRdCost(nonZeroDistU, singleBitsComp[TEXT_CHROMA_U][tuIterator.section], nonZeroPsyEnergyU);
                         else
                             singleCostU = m_rdCost.calcRdCost(nonZeroDistU, singleBitsComp[TEXT_CHROMA_U][tuIterator.section]);
-                        m_entropyCoder->resetBits();
-                        m_entropyCoder->codeQtCbfZero(TEXT_CHROMA_U, trMode);
-                        const uint32_t nullBitsU = m_entropyCoder->getNumberOfWrittenBits();
+                        m_entropyCoder.resetBits();
+                        m_entropyCoder.codeQtCbfZero(TEXT_CHROMA_U, trMode);
+                        const uint32_t nullBitsU = m_entropyCoder.getNumberOfWrittenBits();
                         uint64_t nullCostU = 0;
                         if (m_rdCost.m_psyRd)
                             nullCostU = m_rdCost.calcPsyRdCost(distU, nullBitsU, psyEnergyU);
@@ -2721,9 +2721,9 @@
                 }
                 else if (checkTransformSkipUV)
                 {
-                    m_entropyCoder->resetBits();
-                    m_entropyCoder->codeQtCbfZero(TEXT_CHROMA_U, trModeC);
-                    const uint32_t nullBitsU = m_entropyCoder->getNumberOfWrittenBits();
+                    m_entropyCoder.resetBits();
+                    m_entropyCoder.codeQtCbfZero(TEXT_CHROMA_U, trModeC);
+                    const uint32_t nullBitsU = m_entropyCoder.getNumberOfWrittenBits();
                     if (m_rdCost.m_psyRd)
                         minCost[TEXT_CHROMA_U][tuIterator.section] = m_rdCost.calcPsyRdCost(distU, nullBitsU, psyEnergyU);
                     else
@@ -2775,9 +2775,9 @@
                             singleCostV = m_rdCost.calcPsyRdCost(nonZeroDistV, singleBitsComp[TEXT_CHROMA_V][tuIterator.section], nonZeroPsyEnergyV);
                         else
                             singleCostV = m_rdCost.calcRdCost(nonZeroDistV, singleBitsComp[TEXT_CHROMA_V][tuIterator.section]);
-                        m_entropyCoder->resetBits();
-                        m_entropyCoder->codeQtCbfZero(TEXT_CHROMA_V, trMode);
-                        const uint32_t nullBitsV = m_entropyCoder->getNumberOfWrittenBits();
+                        m_entropyCoder.resetBits();
+                        m_entropyCoder.codeQtCbfZero(TEXT_CHROMA_V, trMode);
+                        const uint32_t nullBitsV = m_entropyCoder.getNumberOfWrittenBits();
                         uint64_t nullCostV = 0;
                         if (m_rdCost.m_psyRd)
                             nullCostV = m_rdCost.calcPsyRdCost(distV, nullBitsV, psyEnergyV);
@@ -2803,9 +2803,9 @@
                 }
                 else if (checkTransformSkipUV)
                 {
-                    m_entropyCoder->resetBits();
-                    m_entropyCoder->codeQtCbfZero(TEXT_CHROMA_V, trModeC);
-                    const uint32_t nullBitsV = m_entropyCoder->getNumberOfWrittenBits();
+                    m_entropyCoder.resetBits();
+                    m_entropyCoder.codeQtCbfZero(TEXT_CHROMA_V, trModeC);
+                    const uint32_t nullBitsV = m_entropyCoder.getNumberOfWrittenBits();
                     if (m_rdCost.m_psyRd)
                         minCost[TEXT_CHROMA_V][tuIterator.section] = m_rdCost.calcPsyRdCost(distV, nullBitsV, psyEnergyV);
                     else
@@ -2833,12 +2833,12 @@
             ALIGN_VAR_32(coeff_t, tsCoeffY[MAX_TS_SIZE * MAX_TS_SIZE]);
             ALIGN_VAR_32(int16_t, tsResiY[MAX_TS_SIZE * MAX_TS_SIZE]);
 
-            m_entropyCoder->load(m_rdEntropyCoders[depth][CI_QT_TRAFO_ROOT]);
+            m_entropyCoder.load(m_rdEntropyCoders[depth][CI_QT_TRAFO_ROOT]);
 
             cu->setTransformSkipSubParts(1, TEXT_LUMA, absPartIdx, depth);
 
             if (m_bEnableRDOQ)
-                m_entropyCoder->estBit(m_entropyCoder->m_estBitsSbac, log2TrSize, true);
+                m_entropyCoder.estBit(m_entropyCoder.m_estBitsSbac, log2TrSize, true);
 
             uint32_t numSigTSkipY = m_quant.transformNxN(cu, fencYuv->getLumaAddr(absPartIdx), fencYuv->getStride(), resiYuv->getLumaAddr(absPartIdx), resiYuv->m_width, tsCoeffY,
                                                          log2TrSize, TEXT_LUMA, absPartIdx, true);
@@ -2846,10 +2846,10 @@
 
             if (numSigTSkipY)
             {
-                m_entropyCoder->resetBits();
-                m_entropyCoder->codeQtCbf(cu, absPartIdx, TEXT_LUMA, trMode);
-                m_entropyCoder->codeCoeffNxN(cu, tsCoeffY, absPartIdx, log2TrSize, TEXT_LUMA);
-                const uint32_t skipSingleBitsY = m_entropyCoder->getNumberOfWrittenBits();
+                m_entropyCoder.resetBits();
+                m_entropyCoder.codeQtCbf(cu, absPartIdx, TEXT_LUMA, trMode);
+                m_entropyCoder.codeCoeffNxN(cu, tsCoeffY, absPartIdx, log2TrSize, TEXT_LUMA);
+                const uint32_t skipSingleBitsY = m_entropyCoder.getNumberOfWrittenBits();
 
                 m_quant.invtransformNxN(cu->getCUTransquantBypass(absPartIdx), tsResiY, trSize, tsCoeffY, log2TrSize, TEXT_LUMA, false, true, numSigTSkipY);
 
@@ -2896,7 +2896,7 @@
             uint64_t singleCostU = MAX_INT64;
             uint64_t singleCostV = MAX_INT64;
 
-            m_entropyCoder->load(m_rdEntropyCoders[depth][CI_QT_TRAFO_ROOT]);
+            m_entropyCoder.load(m_rdEntropyCoders[depth][CI_QT_TRAFO_ROOT]);
 
             TURecurse tuIterator(splitIntoSubTUs ? VERTICAL_SPLIT : DONT_SPLIT, absPartIdxStep, absPartIdx);
 
@@ -2919,7 +2919,7 @@
                 cu->setTransformSkipPartRange(1, TEXT_CHROMA_V, absPartIdxC, tuIterator.absPartIdxStep);
 
                 if (m_bEnableRDOQ)
-                    m_entropyCoder->estBit(m_entropyCoder->m_estBitsSbac, log2TrSizeC, false);
+                    m_entropyCoder.estBit(m_entropyCoder.m_estBitsSbac, log2TrSizeC, false);
 
                 uint32_t numSigTSkipU = m_quant.transformNxN(cu, fencYuv->getCbAddr(absPartIdxC), fencYuv->getCStride(), resiYuv->getCbAddr(absPartIdxC), resiYuv->m_cwidth, tsCoeffU,
                                                              log2TrSizeC, TEXT_CHROMA_U, absPartIdxC, true);
@@ -2929,14 +2929,14 @@
                 cu->setCbfPartRange(numSigTSkipU ? setCbf : 0, TEXT_CHROMA_U, absPartIdxC, tuIterator.absPartIdxStep);
                 cu->setCbfPartRange(numSigTSkipV ? setCbf : 0, TEXT_CHROMA_V, absPartIdxC, tuIterator.absPartIdxStep);
 
-                m_entropyCoder->resetBits();
+                m_entropyCoder.resetBits();
                 singleBitsComp[TEXT_CHROMA_U][tuIterator.section] = 0;
 
                 if (numSigTSkipU)
                 {
-                    m_entropyCoder->codeQtCbf(cu, absPartIdxC, TEXT_CHROMA_U, trMode);
-                    m_entropyCoder->codeCoeffNxN(cu, tsCoeffU, absPartIdxC, log2TrSizeC, TEXT_CHROMA_U);
-                    singleBitsComp[TEXT_CHROMA_U][tuIterator.section] = m_entropyCoder->getNumberOfWrittenBits();
+                    m_entropyCoder.codeQtCbf(cu, absPartIdxC, TEXT_CHROMA_U, trMode);
+                    m_entropyCoder.codeCoeffNxN(cu, tsCoeffU, absPartIdxC, log2TrSizeC, TEXT_CHROMA_U);
+                    singleBitsComp[TEXT_CHROMA_U][tuIterator.section] = m_entropyCoder.getNumberOfWrittenBits();
 
                     m_quant.invtransformNxN(cu->getCUTransquantBypass(absPartIdxC), tsResiU, trSizeC, tsCoeffU,
                                             log2TrSizeC, TEXT_CHROMA_U, false, true, numSigTSkipU);
@@ -2975,9 +2975,9 @@
 
                 if (numSigTSkipV)
                 {
-                    m_entropyCoder->codeQtCbf(cu, absPartIdxC, TEXT_CHROMA_V, trMode);
-                    m_entropyCoder->codeCoeffNxN(cu, tsCoeffV, absPartIdxC, log2TrSizeC, TEXT_CHROMA_V);
-                    singleBitsComp[TEXT_CHROMA_V][tuIterator.section] = m_entropyCoder->getNumberOfWrittenBits() - singleBitsComp[TEXT_CHROMA_U][tuIterator.section];
+                    m_entropyCoder.codeQtCbf(cu, absPartIdxC, TEXT_CHROMA_V, trMode);
+                    m_entropyCoder.codeCoeffNxN(cu, tsCoeffV, absPartIdxC, log2TrSizeC, TEXT_CHROMA_V);
+                    singleBitsComp[TEXT_CHROMA_V][tuIterator.section] = m_entropyCoder.getNumberOfWrittenBits() - singleBitsComp[TEXT_CHROMA_U][tuIterator.section];
 
                     m_quant.invtransformNxN(cu->getCUTransquantBypass(absPartIdxC), tsResiV, trSizeC, tsCoeffV,
                                             log2TrSizeC, TEXT_CHROMA_V, false, true, numSigTSkipV);
@@ -3020,12 +3020,12 @@
             while (tuIterator.isNextSection());
         }
 
-        m_entropyCoder->load(m_rdEntropyCoders[depth][CI_QT_TRAFO_ROOT]);
-
-        m_entropyCoder->resetBits();
+        m_entropyCoder.load(m_rdEntropyCoders[depth][CI_QT_TRAFO_ROOT]);
+
+        m_entropyCoder.resetBits();
 
         if (log2TrSize > depthRange[0])
-            m_entropyCoder->codeTransformSubdivFlag(0, 5 - log2TrSize);
+            m_entropyCoder.codeTransformSubdivFlag(0, 5 - log2TrSize);
 
         if (bCodeChroma)
         {
@@ -3036,22 +3036,22 @@
             }
 
             uint32_t trHeightC = (m_csp == X265_CSP_I422) ? (trSizeC << 1) : trSizeC;
-            m_entropyCoder->codeQtCbf(cu, absPartIdx, absPartIdxStep, trSizeC, trHeightC, TEXT_CHROMA_U, trMode, true);
-            m_entropyCoder->codeQtCbf(cu, absPartIdx, absPartIdxStep, trSizeC, trHeightC, TEXT_CHROMA_V, trMode, true);
+            m_entropyCoder.codeQtCbf(cu, absPartIdx, absPartIdxStep, trSizeC, trHeightC, TEXT_CHROMA_U, trMode, true);
+            m_entropyCoder.codeQtCbf(cu, absPartIdx, absPartIdxStep, trSizeC, trHeightC, TEXT_CHROMA_V, trMode, true);
         }
 
-        m_entropyCoder->codeQtCbf(cu, absPartIdx, TEXT_LUMA, trMode);
+        m_entropyCoder.codeQtCbf(cu, absPartIdx, TEXT_LUMA, trMode);
         if (numSigY)
-            m_entropyCoder->codeCoeffNxN(cu, coeffCurY, absPartIdx, log2TrSize, TEXT_LUMA);
+            m_entropyCoder.codeCoeffNxN(cu, coeffCurY, absPartIdx, log2TrSize, TEXT_LUMA);
 
         if (bCodeChroma)
         {
             if (!splitIntoSubTUs)
             {
                 if (numSigU[0])
-                    m_entropyCoder->codeCoeffNxN(cu, coeffCurU, absPartIdx, log2TrSizeC, TEXT_CHROMA_U);
+                    m_entropyCoder.codeCoeffNxN(cu, coeffCurU, absPartIdx, log2TrSizeC, TEXT_CHROMA_U);
                 if (numSigV[0])
-                    m_entropyCoder->codeCoeffNxN(cu, coeffCurV, absPartIdx, log2TrSizeC, TEXT_CHROMA_V);
+                    m_entropyCoder.codeCoeffNxN(cu, coeffCurV, absPartIdx, log2TrSizeC, TEXT_CHROMA_V);
             }
             else
             {
@@ -3059,13 +3059,13 @@
                 uint32_t partIdxesPerSubTU = absPartIdxStep >> 1;
 
                 if (numSigU[0])
-                    m_entropyCoder->codeCoeffNxN(cu, coeffCurU, absPartIdx, log2TrSizeC, TEXT_CHROMA_U);
+                    m_entropyCoder.codeCoeffNxN(cu, coeffCurU, absPartIdx, log2TrSizeC, TEXT_CHROMA_U);
                 if (numSigU[1])
-                    m_entropyCoder->codeCoeffNxN(cu, coeffCurU + subTUSize, absPartIdx + partIdxesPerSubTU, log2TrSizeC, TEXT_CHROMA_U);
+                    m_entropyCoder.codeCoeffNxN(cu, coeffCurU + subTUSize, absPartIdx + partIdxesPerSubTU, log2TrSizeC, TEXT_CHROMA_U);
                 if (numSigV[0])
-                    m_entropyCoder->codeCoeffNxN(cu, coeffCurV, absPartIdx, log2TrSizeC, TEXT_CHROMA_V);
+                    m_entropyCoder.codeCoeffNxN(cu, coeffCurV, absPartIdx, log2TrSizeC, TEXT_CHROMA_V);
                 if (numSigV[1])
-                    m_entropyCoder->codeCoeffNxN(cu, coeffCurV + subTUSize, absPartIdx + partIdxesPerSubTU, log2TrSizeC, TEXT_CHROMA_V);
+                    m_entropyCoder.codeCoeffNxN(cu, coeffCurV + subTUSize, absPartIdx + partIdxesPerSubTU, log2TrSizeC, TEXT_CHROMA_V);
             }
         }
 
@@ -3077,7 +3077,7 @@
             singleDist += singleDistComp[TEXT_CHROMA_V][subTUIndex];
         }
 
-        singleBits = m_entropyCoder->getNumberOfWrittenBits();
+        singleBits = m_entropyCoder.getNumberOfWrittenBits();
         if (m_rdCost.m_psyRd)
             singleCost = m_rdCost.calcPsyRdCost(singleDist, singleBits, singlePsyEnergy);
         else
@@ -3104,8 +3104,8 @@
     {
         if (bCheckFull)
         {
-            m_entropyCoder->store(m_rdEntropyCoders[depth][CI_QT_TRAFO_TEST]);
-            m_entropyCoder->load(m_rdEntropyCoders[depth][CI_QT_TRAFO_ROOT]);
+            m_entropyCoder.store(m_rdEntropyCoders[depth][CI_QT_TRAFO_TEST]);
+            m_entropyCoder.load(m_rdEntropyCoders[depth][CI_QT_TRAFO_ROOT]);
         }
         uint32_t subdivDist = 0;
         uint32_t subdivBits = 0;
@@ -3151,15 +3151,15 @@
             cu->getCbf(TEXT_CHROMA_V)[absPartIdx + i] |= vcbf << trMode;
         }
 
-        m_entropyCoder->load(m_rdEntropyCoders[depth][CI_QT_TRAFO_ROOT]);
-        m_entropyCoder->resetBits();
+        m_entropyCoder.load(m_rdEntropyCoders[depth][CI_QT_TRAFO_ROOT]);
+        m_entropyCoder.resetBits();
 
         xEncodeResidualQT(cu, absPartIdx, depth, true,  TEXT_LUMA, depthRange);
         xEncodeResidualQT(cu, absPartIdx, depth, false, TEXT_LUMA, depthRange);
         xEncodeResidualQT(cu, absPartIdx, depth, false, TEXT_CHROMA_U, depthRange);
         xEncodeResidualQT(cu, absPartIdx, depth, false, TEXT_CHROMA_V, depthRange);
 
-        subdivBits = m_entropyCoder->getNumberOfWrittenBits();
+        subdivBits = m_entropyCoder.getNumberOfWrittenBits();
 
         if (m_rdCost.m_psyRd)
             subDivCost = m_rdCost.calcPsyRdCost(subdivDist, subdivBits, subDivPsyEnergy);
@@ -3195,7 +3195,7 @@
             }
         }
         X265_CHECK(bCheckFull, "check-full must be set\n");
-        m_entropyCoder->load(m_rdEntropyCoders[depth][CI_QT_TRAFO_TEST]);
+        m_entropyCoder.load(m_rdEntropyCoders[depth][CI_QT_TRAFO_TEST]);
     }
 
     rdCost += singleCost;
@@ -3246,7 +3246,7 @@
     const bool splitIntoSubTUs = (m_csp == X265_CSP_I422);
 
     if (bSubdivAndCbf && log2TrSize <= depthRange[1] && log2TrSize > depthRange[0])
-        m_entropyCoder->codeTransformSubdivFlag(bSubdiv, 5 - log2TrSize);
+        m_entropyCoder.codeTransformSubdivFlag(bSubdiv, 5 - log2TrSize);
 
     X265_CHECK(cu->getPredictionMode(absPartIdx) != MODE_INTRA, "xEncodeResidualQT() with intra block\n");
 
@@ -3265,9 +3265,9 @@
         {
             uint32_t absPartIdxStep = NUM_CU_PARTITIONS >> ((cu->getDepth(0) +  curTrMode) << 1);
             if (bFirstCbfOfCU || cu->getCbf(absPartIdx, TEXT_CHROMA_U, curTrMode - 1))
-                m_entropyCoder->codeQtCbf(cu, absPartIdx, absPartIdxStep, trWidthC, trHeightC, TEXT_CHROMA_U, curTrMode, !bSubdiv);
+                m_entropyCoder.codeQtCbf(cu, absPartIdx, absPartIdxStep, trWidthC, trHeightC, TEXT_CHROMA_U, curTrMode, !bSubdiv);
             if (bFirstCbfOfCU || cu->getCbf(absPartIdx, TEXT_CHROMA_V, curTrMode - 1))
-                m_entropyCoder->codeQtCbf(cu, absPartIdx, absPartIdxStep, trWidthC, trHeightC, TEXT_CHROMA_V, curTrMode, !bSubdiv);
+                m_entropyCoder.codeQtCbf(cu, absPartIdx, absPartIdxStep, trWidthC, trHeightC, TEXT_CHROMA_V, curTrMode, !bSubdiv);
         }
         else
         {
@@ -3295,11 +3295,11 @@
         }
 
         if (bSubdivAndCbf)
-            m_entropyCoder->codeQtCbf(cu, absPartIdx, TEXT_LUMA, trMode);
+            m_entropyCoder.codeQtCbf(cu, absPartIdx, TEXT_LUMA, trMode);
         else
         {
             if (ttype == TEXT_LUMA && cu->getCbf(absPartIdx, TEXT_LUMA, trMode))
-                m_entropyCoder->codeCoeffNxN(cu, coeffCurY, absPartIdx, log2TrSize, TEXT_LUMA);
+                m_entropyCoder.codeCoeffNxN(cu, coeffCurY, absPartIdx, log2TrSize, TEXT_LUMA);
 
             if (bCodeChroma)
             {
@@ -3310,9 +3310,9 @@
                 if (!splitIntoSubTUs)
                 {
                     if (ttype == TEXT_CHROMA_U && cu->getCbf(absPartIdx, TEXT_CHROMA_U, trMode))
-                        m_entropyCoder->codeCoeffNxN(cu, coeffCurU, absPartIdx, log2TrSizeC, TEXT_CHROMA_U);
+                        m_entropyCoder.codeCoeffNxN(cu, coeffCurU, absPartIdx, log2TrSizeC, TEXT_CHROMA_U);
                     if (ttype == TEXT_CHROMA_V && cu->getCbf(absPartIdx, TEXT_CHROMA_V, trMode))
-                        m_entropyCoder->codeCoeffNxN(cu, coeffCurV, absPartIdx, log2TrSizeC, TEXT_CHROMA_V);
+                        m_entropyCoder.codeCoeffNxN(cu, coeffCurV, absPartIdx, log2TrSizeC, TEXT_CHROMA_V);
                 }
                 else
                 {
@@ -3321,16 +3321,16 @@
                     if (ttype == TEXT_CHROMA_U && cu->getCbf(absPartIdx, TEXT_CHROMA_U, trMode))
                     {
                         if (cu->getCbf(absPartIdx, ttype, trMode + 1))
-                            m_entropyCoder->codeCoeffNxN(cu, coeffCurU, absPartIdx, log2TrSizeC, TEXT_CHROMA_U);
+                            m_entropyCoder.codeCoeffNxN(cu, coeffCurU, absPartIdx, log2TrSizeC, TEXT_CHROMA_U);
                         if (cu->getCbf(absPartIdx + partIdxesPerSubTU, ttype, trMode + 1))
-                            m_entropyCoder->codeCoeffNxN(cu, coeffCurU + subTUSize, absPartIdx + partIdxesPerSubTU, log2TrSizeC, TEXT_CHROMA_U);
+                            m_entropyCoder.codeCoeffNxN(cu, coeffCurU + subTUSize, absPartIdx + partIdxesPerSubTU, log2TrSizeC, TEXT_CHROMA_U);
                     }
                     if (ttype == TEXT_CHROMA_V && cu->getCbf(absPartIdx, TEXT_CHROMA_V, trMode))
                     {
                         if (cu->getCbf(absPartIdx, ttype, trMode + 1))
-                            m_entropyCoder->codeCoeffNxN(cu, coeffCurV, absPartIdx, log2TrSizeC, TEXT_CHROMA_V);
+                            m_entropyCoder.codeCoeffNxN(cu, coeffCurV, absPartIdx, log2TrSizeC, TEXT_CHROMA_V);
                         if (cu->getCbf(absPartIdx + partIdxesPerSubTU, ttype, trMode + 1))
-                            m_entropyCoder->codeCoeffNxN(cu, coeffCurV + subTUSize, absPartIdx + partIdxesPerSubTU, log2TrSizeC, TEXT_CHROMA_V);
+                            m_entropyCoder.codeCoeffNxN(cu, coeffCurV + subTUSize, absPartIdx + partIdxesPerSubTU, log2TrSizeC, TEXT_CHROMA_V);
                     }
                 }
             }
@@ -3410,14 +3410,14 @@
 uint32_t Search::getIntraModeBits(TComDataCU* cu, uint32_t mode, uint32_t partOffset, uint32_t depth)
 {
     // Reload only contexts required for coding intra mode information
-    m_entropyCoder->loadIntraDirModeLuma(m_rdEntropyCoders[depth][CI_CURR_BEST]);
+    m_entropyCoder.loadIntraDirModeLuma(m_rdEntropyCoders[depth][CI_CURR_BEST]);
 
     cu->getLumaIntraDir()[partOffset] = (uint8_t)mode;
 
-    m_entropyCoder->resetBits();
-    m_entropyCoder->codeIntraDirLumaAng(cu, partOffset, false);
-
-    return m_entropyCoder->getNumberOfWrittenBits();
+    m_entropyCoder.resetBits();
+    m_entropyCoder.codeIntraDirLumaAng(cu, partOffset, false);
+
+    return m_entropyCoder.getNumberOfWrittenBits();
 }
 
 /* returns the number of bits required to signal a non-most-probable mode.
@@ -3465,32 +3465,32 @@
     {
         cu->setSkipFlagSubParts(true, 0, cu->getDepth(0));
 
-        m_entropyCoder->resetBits();
+        m_entropyCoder.resetBits();
         if (cu->m_slice->m_pps->bTransquantBypassEnabled)
-            m_entropyCoder->codeCUTransquantBypassFlag(cu->getCUTransquantBypass(0));
+            m_entropyCoder.codeCUTransquantBypassFlag(cu->getCUTransquantBypass(0));
         if (!cu->m_slice->isIntra())
-            m_entropyCoder->codeSkipFlag(cu, 0);
-        m_entropyCoder->codeMergeIndex(cu, 0);
-        cu->m_mvBits = m_entropyCoder->getNumberOfWrittenBits();
+            m_entropyCoder.codeSkipFlag(cu, 0);
+        m_entropyCoder.codeMergeIndex(cu, 0);
+        cu->m_mvBits = m_entropyCoder.getNumberOfWrittenBits();
         cu->m_coeffBits = 0;
-        return m_entropyCoder->getNumberOfWrittenBits();
+        return m_entropyCoder.getNumberOfWrittenBits();
     }
     else
     {
-        m_entropyCoder->resetBits();
+        m_entropyCoder.resetBits();
         if (cu->m_slice->m_pps->bTransquantBypassEnabled)
-            m_entropyCoder->codeCUTransquantBypassFlag(cu->getCUTransquantBypass(0));
+            m_entropyCoder.codeCUTransquantBypassFlag(cu->getCUTransquantBypass(0));
         if (!cu->m_slice->isIntra())
         {
-            m_entropyCoder->codeSkipFlag(cu, 0);
-            m_entropyCoder->codePredMode(cu->getPredictionMode(0));
+            m_entropyCoder.codeSkipFlag(cu, 0);
+            m_entropyCoder.codePredMode(cu->getPredictionMode(0));
         }
-        m_entropyCoder->codePartSize(cu, 0, cu->getDepth(0));
-        m_entropyCoder->codePredInfo(cu, 0);
+        m_entropyCoder.codePartSize(cu, 0, cu->getDepth(0));
+        m_entropyCoder.codePredInfo(cu, 0);
         bool bDummy = false;
-        cu->m_mvBits = m_entropyCoder->getNumberOfWrittenBits();
-        m_entropyCoder->codeCoeff(cu, 0, cu->getDepth(0), bDummy, depthRange);
-        int totalBits = m_entropyCoder->getNumberOfWrittenBits();
+        cu->m_mvBits = m_entropyCoder.getNumberOfWrittenBits();
+        m_entropyCoder.codeCoeff(cu, 0, cu->getDepth(0), bDummy, depthRange);
+        int totalBits = m_entropyCoder.getNumberOfWrittenBits();
         cu->m_coeffBits = totalBits - cu->m_mvBits;
         return totalBits;
     }
diff -r 9cc2a85e1f07 -r 58e21257c7df source/encoder/search.h
--- a/source/encoder/search.h	Thu Sep 25 15:09:01 2014 -0500
+++ b/source/encoder/search.h	Thu Sep 25 17:57:44 2014 -0500
@@ -34,6 +34,7 @@
 #include "TLibCommon/TComPattern.h"
 
 #include "rdcost.h"
+#include "entropy.h"
 #include "motion.h"
 
 #define MVP_IDX_BITS 1
@@ -60,7 +61,7 @@
     RDCost          m_rdCost;
     x265_param*     m_param;
 
-    Entropy*        m_entropyCoder;
+    Entropy         m_entropyCoder;
     Entropy       (*m_rdEntropyCoders)[CI_NUM];
 
     TComYuv         m_predTempYuv;


More information about the x265-devel mailing list