[x265] [PATCH] Entropy: Replaced getCtxQtCbf() with table
ashok at multicorewareinc.com
ashok at multicorewareinc.com
Mon Sep 1 13:15:11 CEST 2014
# HG changeset patch
# User Ashok Kumar Mishra<ashok at multicorewareinc.com>
# Date 1409570084 -19800
# Mon Sep 01 16:44:44 2014 +0530
# Node ID 470f37c080116da877cfb6fd7668a5652dc3b7a6
# Parent 0ed902cbbb61d349d51ce9fea77a0f15dfef5911
Entropy: Replaced getCtxQtCbf() with table
diff -r 0ed902cbbb61 -r 470f37c08011 source/Lib/TLibCommon/ContextTables.h
--- a/source/Lib/TLibCommon/ContextTables.h Thu Aug 28 13:14:34 2014 +0530
+++ b/source/Lib/TLibCommon/ContextTables.h Mon Sep 01 16:44:44 2014 +0530
@@ -144,6 +144,7 @@
#define NEIGHBOURHOOD_00_CONTEXT_1_THRESHOLD_4x4 3
#define NEIGHBOURHOOD_00_CONTEXT_2_THRESHOLD_4x4 1
+static const uint32_t ctxCbf[3][3] = { { 1, 0, 0 }, { 2, 3, 4 }, { 2, 3, 4} };
static const uint32_t significanceMapContextSetStart[MAX_NUM_CHANNEL_TYPE][3] = { { 0, 9, 21 }, { 0, 9, 12 } };
static const uint32_t significanceMapContextSetSize[MAX_NUM_CHANNEL_TYPE][3] = { { 9, 12, 6 }, { 9, 3, 3 } };
static const uint32_t nonDiagonalScan8x8ContextOffset[MAX_NUM_CHANNEL_TYPE] = { 6, 0 };
diff -r 0ed902cbbb61 -r 470f37c08011 source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp Thu Aug 28 13:14:34 2014 +0530
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp Mon Sep 01 16:44:44 2014 +0530
@@ -2798,7 +2798,7 @@
else
singleCostY = m_rdCost.calcRdCost(nonZeroDistY, singleBitsComp[TEXT_LUMA][0]);
m_entropyCoder->resetBits();
- m_entropyCoder->codeQtCbfZero(cu, TEXT_LUMA, trMode);
+ m_entropyCoder->codeQtCbfZero(TEXT_LUMA, trMode);
const uint32_t nullBitsY = m_entropyCoder->getNumberOfWrittenBits();
uint64_t nullCostY = 0;
if (m_rdCost.m_psyRd)
@@ -2826,7 +2826,7 @@
else if (checkTransformSkipY)
{
m_entropyCoder->resetBits();
- m_entropyCoder->codeQtCbfZero(cu, TEXT_LUMA, trMode);
+ 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);
@@ -2898,7 +2898,7 @@
else
singleCostU = m_rdCost.calcRdCost(nonZeroDistU, singleBitsComp[TEXT_CHROMA_U][tuIterator.section]);
m_entropyCoder->resetBits();
- m_entropyCoder->codeQtCbfZero(cu, TEXT_CHROMA_U, trMode);
+ m_entropyCoder->codeQtCbfZero(TEXT_CHROMA_U, trMode);
const uint32_t nullBitsU = m_entropyCoder->getNumberOfWrittenBits();
uint64_t nullCostU = 0;
if (m_rdCost.m_psyRd)
@@ -2926,7 +2926,7 @@
else if (checkTransformSkipUV)
{
m_entropyCoder->resetBits();
- m_entropyCoder->codeQtCbfZero(cu, TEXT_CHROMA_U, trModeC);
+ 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);
@@ -2980,7 +2980,7 @@
else
singleCostV = m_rdCost.calcRdCost(nonZeroDistV, singleBitsComp[TEXT_CHROMA_V][tuIterator.section]);
m_entropyCoder->resetBits();
- m_entropyCoder->codeQtCbfZero(cu, TEXT_CHROMA_V, trMode);
+ m_entropyCoder->codeQtCbfZero(TEXT_CHROMA_V, trMode);
const uint32_t nullBitsV = m_entropyCoder->getNumberOfWrittenBits();
uint64_t nullCostV = 0;
if (m_rdCost.m_psyRd)
@@ -3008,7 +3008,7 @@
else if (checkTransformSkipUV)
{
m_entropyCoder->resetBits();
- m_entropyCoder->codeQtCbfZero(cu, TEXT_CHROMA_V, trModeC);
+ 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);
diff -r 0ed902cbbb61 -r 470f37c08011 source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp Thu Aug 28 13:14:34 2014 +0530
+++ b/source/encoder/entropy.cpp Mon Sep 01 16:44:44 2014 +0530
@@ -1469,7 +1469,7 @@
void Entropy::codeQtCbf(TComDataCU* cu, uint32_t absPartIdx, uint32_t absPartIdxStep, uint32_t width, uint32_t height, TextType ttype, uint32_t trDepth, bool lowestLevel)
{
- uint32_t ctx = cu->getCtxQtCbf(ttype, trDepth);
+ uint32_t ctx = ctxCbf[ttype][trDepth];
bool canQuadSplit = (width >= (MIN_TU_SIZE * 2)) && (height >= (MIN_TU_SIZE * 2));
uint32_t lowestTUDepth = trDepth + ((!lowestLevel && !canQuadSplit) ? 1 : 0); // unsplittable TUs inherit their parent's CBF
@@ -1498,7 +1498,7 @@
void Entropy::codeQtCbf(TComDataCU* cu, uint32_t absPartIdx, TextType ttype, uint32_t trDepth)
{
- uint32_t ctx = cu->getCtxQtCbf(ttype, trDepth);
+ uint32_t ctx = ctxCbf[ttype][trDepth];
uint32_t cbf = cu->getCbf(absPartIdx, ttype, trDepth);
encodeBin(cbf, m_contextState[OFF_QT_CBF_CTX + ctx]);
}
@@ -1522,14 +1522,12 @@
encodeBin(cbf, m_contextState[OFF_QT_ROOT_CBF_CTX + ctx]);
}
-void Entropy::codeQtCbfZero(TComDataCU* cu, TextType ttype, uint32_t trDepth)
+void Entropy::codeQtCbfZero(TextType ttype, uint32_t trDepth)
{
// this function is only used to estimate the bits when cbf is 0
// and will never be called when writing the bistream. do not need to write log
- uint32_t cbf = 0;
- uint32_t ctx = cu->getCtxQtCbf(ttype, trDepth);
-
- encodeBin(cbf, m_contextState[OFF_QT_CBF_CTX + ctx]);
+ uint32_t ctx = ctxCbf[ttype][trDepth];
+ encodeBin(0, m_contextState[OFF_QT_CBF_CTX + ctx]);
}
void Entropy::codeQtRootCbfZero(TComDataCU*)
diff -r 0ed902cbbb61 -r 470f37c08011 source/encoder/entropy.h
--- a/source/encoder/entropy.h Thu Aug 28 13:14:34 2014 +0530
+++ b/source/encoder/entropy.h Mon Sep 01 16:44:44 2014 +0530
@@ -39,6 +39,7 @@
class TComDataCU;
class ScalingList;
+
enum SplitType
{
DONT_SPLIT = 0,
@@ -167,7 +168,7 @@
void codeTransformSubdivFlag(uint32_t symbol, uint32_t ctx);
void codeQtCbf(TComDataCU* cu, uint32_t absPartIdx, uint32_t absPartIdxStep, uint32_t width, uint32_t height, TextType ttype, uint32_t trDepth, bool lowestLevel);
void codeQtCbf(TComDataCU* cu, uint32_t absPartIdx, TextType ttype, uint32_t trDepth);
- void codeQtCbfZero(TComDataCU* cu, TextType ttype, uint32_t trDepth);
+ void codeQtCbfZero(TextType ttype, uint32_t trDepth);
void codeQtRootCbfZero(TComDataCU* cu);
void codeCoeff(TComDataCU* cu, uint32_t absPartIdx, uint32_t depth, bool& bCodeDQP);
void codeCoeffNxN(TComDataCU* cu, coeff_t* coef, uint32_t absPartIdx, uint32_t log2TrSize, TextType ttype);
More information about the x265-devel
mailing list