[x265] constants: g_zscanToRaster, g_rasterToZscan as const table
Satoshi Nakagawa
nakagawa424 at oki.com
Tue Jul 5 13:57:04 CEST 2016
# HG changeset patch
# User Satoshi Nakagawa <nakagawa424 at oki.com>
# Date 1467719659 -32400
# Tue Jul 05 20:54:19 2016 +0900
# Node ID cf06a60ee646199cf4f139a5c22cff7ac5626d68
# Parent a932b4366235ab6597c8d124c1569dade6ff790a
constants: g_zscanToRaster, g_rasterToZscan as const table
diff -r a932b4366235 -r cf06a60ee646 source/common/common.h
--- a/source/common/common.h Mon Jul 04 21:25:59 2016 +0530
+++ b/source/common/common.h Tue Jul 05 20:54:19 2016 +0900
@@ -255,7 +255,9 @@
#define LOG2_UNIT_SIZE 2 // log2(unitSize)
#define UNIT_SIZE (1 << LOG2_UNIT_SIZE) // unit size of CU partition
-#define MAX_NUM_PARTITIONS 256
+#define LOG2_RASTER_SIZE (MAX_LOG2_CU_SIZE - LOG2_UNIT_SIZE)
+#define RASTER_SIZE (1 << LOG2_RASTER_SIZE)
+#define MAX_NUM_PARTITIONS (RASTER_SIZE * RASTER_SIZE)
#define NUM_4x4_PARTITIONS (1U << (g_unitSizeDepth << 1)) // number of 4x4 units in max CU size
#define MIN_PU_SIZE 4
diff -r a932b4366235 -r cf06a60ee646 source/common/constants.cpp
--- a/source/common/constants.cpp Mon Jul 04 21:25:59 2016 +0530
+++ b/source/common/constants.cpp Tue Jul 05 20:54:19 2016 +0900
@@ -166,9 +166,47 @@
uint32_t g_maxCUSize = MAX_CU_SIZE;
uint32_t g_unitSizeDepth = NUM_CU_DEPTH;
uint32_t g_maxCUDepth = NUM_CU_DEPTH - 1;
-uint32_t g_zscanToRaster[MAX_NUM_PARTITIONS] = { 0, };
-uint32_t g_rasterToZscan[MAX_NUM_PARTITIONS] = { 0, };
+const uint32_t g_zscanToRaster[MAX_NUM_PARTITIONS] =
+{
+ 0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13, 0x20, 0x21, 0x30, 0x31, 0x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, 56, 60, 60, 56, 56, 60, 60
};
-void initZscanToRaster(uint32_t maxFullDepth, uint32_t depth, uint32_t startVal, uint32_t*& curIdx)
-{
- uint32_t stride = 1 << maxFullDepth;
-
- if (depth > maxFullDepth)
- {
- curIdx[0] = startVal;
- curIdx++;
- }
- else
- {
- int step = stride >> depth;
- initZscanToRaster(maxFullDepth, depth + 1, startVal, curIdx);
- initZscanToRaster(maxFullDepth, depth + 1, startVal + step, curIdx);
- initZscanToRaster(maxFullDepth, depth + 1, startVal + step * stride, curIdx);
- initZscanToRaster(maxFullDepth, depth + 1, startVal + step * stride + step, curIdx);
- }
-}
-
-void initRasterToZscan(uint32_t maxFullDepth)
-{
- uint32_t numPartitions = 1 << (maxFullDepth * 2);
-
- for (uint32_t i = 0; i < numPartitions; i++)
- g_rasterToZscan[g_zscanToRaster[i]] = i;
-}
-
const int16_t g_lumaFilter[4][NTAPS_LUMA] =
{
{ 0, 0, 0, 64, 0, 0, 0, 0 },
diff -r a932b4366235 -r cf06a60ee646 source/common/constants.h
--- a/source/common/constants.h Mon Jul 04 21:25:59 2016 +0530
+++ b/source/common/constants.h Tue Jul 05 20:54:19 2016 +0900
@@ -32,9 +32,6 @@
extern int g_ctuSizeConfigured;
-void initZscanToRaster(uint32_t maxFullDepth, uint32_t depth, uint32_t startVal, uint32_t*& curIdx);
-void initRasterToZscan(uint32_t maxFullDepth);
-
extern double x265_lambda_tab[QP_MAX_MAX + 1];
extern double x265_lambda2_tab[QP_MAX_MAX + 1];
extern const uint16_t x265_chroma_lambda2_offset_tab[MAX_CHROMA_LAMBDA_OFFSET + 1];
@@ -46,8 +43,8 @@
extern const uint8_t g_chroma422IntraAngleMappingTable[AngleMapping422TableSize];
// flexible conversion from relative to absolute index
-extern uint32_t g_zscanToRaster[MAX_NUM_PARTITIONS];
-extern uint32_t g_rasterToZscan[MAX_NUM_PARTITIONS];
+extern const uint32_t g_zscanToRaster[MAX_NUM_PARTITIONS];
+extern const uint32_t g_rasterToZscan[MAX_NUM_PARTITIONS];
// conversion of partition index to picture pel position
extern const uint8_t g_zscanToPelX[MAX_NUM_PARTITIONS];
diff -r a932b4366235 -r cf06a60ee646 source/common/cudata.cpp
--- a/source/common/cudata.cpp Mon Jul 04 21:25:59 2016 +0530
+++ b/source/common/cudata.cpp Tue Jul 05 20:54:19 2016 +0900
@@ -58,51 +58,46 @@
// file private namespace
/* Check whether 2 addresses point to the same column */
-inline bool isEqualCol(int addrA, int addrB, int numUnits)
+inline bool isEqualCol(int addrA, int addrB)
{
- // addrA % numUnits == addrB % numUnits
- return ((addrA ^ addrB) & (numUnits - 1)) == 0;
+ return ((addrA ^ addrB) & (RASTER_SIZE - 1)) == 0;
}
/* Check whether 2 addresses point to the same row */
-inline bool isEqualRow(int addrA, int addrB, int numUnits)
+inline bool isEqualRow(int addrA, int addrB)
{
- // addrA / numUnits == addrB / numUnits
- return ((addrA ^ addrB) < numUnits);
+ return ((addrA ^ addrB) < RASTER_SIZE);
}
/* Check whether 2 addresses point to the same row or column */
-inline bool isEqualRowOrCol(int addrA, int addrB, int numUnits)
+inline bool isEqualRowOrCol(int addrA, int addrB)
{
- return isEqualCol(addrA, addrB, numUnits) | isEqualRow(addrA, addrB, numUnits);
+ return isEqualCol(addrA, addrB) | isEqualRow(addrA, addrB);
}
/* Check whether one address points to the first column */
-inline bool isZeroCol(int addr, int numUnits)
+inline bool isZeroCol(int addr)
{
- // addr % numUnits == 0
- return (addr & (numUnits - 1)) == 0;
+ return (addr & (RASTER_SIZE - 1)) == 0;
}
/* Check whether one address points to the first row */
-inline bool isZeroRow(int addr, int numUnits)
+inline bool isZeroRow(int addr)
{
- // addr / numUnits == 0
- return (addr < numUnits);
+ return (addr < RASTER_SIZE);
}
/* Check whether one address points to a column whose index is smaller than a given value */
-inline bool lessThanCol(int addr, int val, int numUnits)
+inline bool lessThanCol(int addr, int val)
{
- // addr % numUnits < val
- return (addr & (numUnits - 1)) < val;
+ return (addr & (RASTER_SIZE - 1)) < val;
}
/* Check whether one address points to a row whose index is smaller than a given value */
-inline bool lessThanRow(int addr, int val, int numUnits)
+inline bool lessThanRow(int addr, int val)
{
// addr / numUnits < val
- return addr < val * numUnits;
+ return (addr >> LOG2_RASTER_SIZE) < val;
}
inline MV scaleMv(MV mv, int scale)
@@ -561,11 +556,11 @@
{
uint32_t absPartIdx = g_zscanToRaster[curPartUnitIdx];
- if (!isZeroCol(absPartIdx, s_numPartInCUSize))
+ if (!isZeroCol(absPartIdx))
{
uint32_t absZorderCUIdx = g_zscanToRaster[m_absIdxInCTU];
lPartUnitIdx = g_rasterToZscan[absPartIdx - 1];
- if (isEqualCol(absPartIdx, absZorderCUIdx, s_numPartInCUSize))
+ if (isEqualCol(absPartIdx, absZorderCUIdx))
return m_encData->getPicCTU(m_cuAddr);
else
{
@@ -582,18 +577,18 @@
{
uint32_t absPartIdx = g_zscanToRaster[curPartUnitIdx];
- if (!isZeroRow(absPartIdx, s_numPartInCUSize))
+ if (!isZeroRow(absPartIdx))
{
uint32_t absZorderCUIdx = g_zscanToRaster[m_absIdxInCTU];
- aPartUnitIdx = g_rasterToZscan[absPartIdx - s_numPartInCUSize];
- if (isEqualRow(absPartIdx, absZorderCUIdx, s_numPartInCUSize))
+ aPartUnitIdx = g_rasterToZscan[absPartIdx - RASTER_SIZE];
+ if (isEqualRow(absPartIdx, absZorderCUIdx))
return m_encData->getPicCTU(m_cuAddr);
else
aPartUnitIdx -= m_absIdxInCTU;
return this;
}
- aPartUnitIdx = g_rasterToZscan[absPartIdx + NUM_4x4_PARTITIONS - s_numPartInCUSize];
+ aPartUnitIdx = g_rasterToZscan[absPartIdx + ((s_numPartInCUSize - 1) << LOG2_RASTER_SIZE)];
return m_cuAbove;
}
@@ -601,13 +596,13 @@
{
uint32_t absPartIdx = g_zscanToRaster[curPartUnitIdx];
- if (!isZeroCol(absPartIdx, s_numPartInCUSize))
+ if (!isZeroCol(absPartIdx))
{
- if (!isZeroRow(absPartIdx, s_numPartInCUSize))
+ if (!isZeroRow(absPartIdx))
{
uint32_t absZorderCUIdx = g_zscanToRaster[m_absIdxInCTU];
- alPartUnitIdx = g_rasterToZscan[absPartIdx - s_numPartInCUSize - 1];
- if (isEqualRowOrCol(absPartIdx, absZorderCUIdx, s_numPartInCUSize))
+ alPartUnitIdx = g_rasterToZscan[absPartIdx - RASTER_SIZE - 1];
+ if (isEqualRowOrCol(absPartIdx, absZorderCUIdx))
return m_encData->getPicCTU(m_cuAddr);
else
{
@@ -615,17 +610,17 @@
return this;
}
}
- alPartUnitIdx = g_rasterToZscan[absPartIdx + NUM_4x4_PARTITIONS - s_numPartInCUSize - 1];
+ alPartUnitIdx = g_rasterToZscan[absPartIdx + ((s_numPartInCUSize - 1) << LOG2_RASTER_SIZE) - 1];
return m_cuAbove;
}
- if (!isZeroRow(absPartIdx, s_numPartInCUSize))
+ if (!isZeroRow(absPartIdx))
{
- alPartUnitIdx = g_rasterToZscan[absPartIdx - 1];
+ alPartUnitIdx = g_rasterToZscan[absPartIdx - RASTER_SIZE + s_numPartInCUSize - 1];
return m_cuLeft;
}
- alPartUnitIdx = g_rasterToZscan[NUM_4x4_PARTITIONS - 1];
+ alPartUnitIdx = NUM_4x4_PARTITIONS - 1;
return m_cuAboveLeft;
}
@@ -636,15 +631,15 @@
uint32_t absPartIdxRT = g_zscanToRaster[curPartUnitIdx];
- if (lessThanCol(absPartIdxRT, s_numPartInCUSize - 1, s_numPartInCUSize))
+ if (lessThanCol(absPartIdxRT, s_numPartInCUSize - 1))
{
- if (!isZeroRow(absPartIdxRT, s_numPartInCUSize))
+ if (!isZeroRow(absPartIdxRT))
{
- if (curPartUnitIdx > g_rasterToZscan[absPartIdxRT - s_numPartInCUSize + 1])
+ if (curPartUnitIdx > g_rasterToZscan[absPartIdxRT - RASTER_SIZE + 1])
{
uint32_t absZorderCUIdx = g_zscanToRaster[m_absIdxInCTU] + (1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE)) - 1;
- arPartUnitIdx = g_rasterToZscan[absPartIdxRT - s_numPartInCUSize + 1];
- if (isEqualRowOrCol(absPartIdxRT, absZorderCUIdx, s_numPartInCUSize))
+ arPartUnitIdx = g_rasterToZscan[absPartIdxRT - RASTER_SIZE + 1];
+ if (isEqualRowOrCol(absPartIdxRT, absZorderCUIdx))
return m_encData->getPicCTU(m_cuAddr);
else
{
@@ -654,14 +649,14 @@
}
return NULL;
}
- arPartUnitIdx = g_rasterToZscan[absPartIdxRT + NUM_4x4_PARTITIONS - s_numPartInCUSize + 1];
+ arPartUnitIdx = g_rasterToZscan[absPartIdxRT + ((s_numPartInCUSize - 1) << LOG2_RASTER_SIZE) + 1];
return m_cuAbove;
}
- if (!isZeroRow(absPartIdxRT, s_numPartInCUSize))
+ if (!isZeroRow(absPartIdxRT))
return NULL;
- arPartUnitIdx = g_rasterToZscan[NUM_4x4_PARTITIONS - s_numPartInCUSize];
+ arPartUnitIdx = g_rasterToZscan[(s_numPartInCUSize - 1) << LOG2_RASTER_SIZE];
return m_cuAboveRight;
}
@@ -672,15 +667,15 @@
uint32_t absPartIdxLB = g_zscanToRaster[curPartUnitIdx];
- if (lessThanRow(absPartIdxLB, s_numPartInCUSize - 1, s_numPartInCUSize))
+ if (lessThanRow(absPartIdxLB, s_numPartInCUSize - 1))
{
- if (!isZeroCol(absPartIdxLB, s_numPartInCUSize))
+ if (!isZeroCol(absPartIdxLB))
{
- if (curPartUnitIdx > g_rasterToZscan[absPartIdxLB + s_numPartInCUSize - 1])
+ if (curPartUnitIdx > g_rasterToZscan[absPartIdxLB + RASTER_SIZE - 1])
{
- uint32_t absZorderCUIdxLB = g_zscanToRaster[m_absIdxInCTU] + ((1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE)) - 1) * s_numPartInCUSize;
- blPartUnitIdx = g_rasterToZscan[absPartIdxLB + s_numPartInCUSize - 1];
- if (isEqualRowOrCol(absPartIdxLB, absZorderCUIdxLB, s_numPartInCUSize))
+ uint32_t absZorderCUIdxLB = g_zscanToRaster[m_absIdxInCTU] + (((1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE)) - 1) << LOG2_RASTER_SIZE);
+ blPartUnitIdx = g_rasterToZscan[absPartIdxLB + RASTER_SIZE - 1];
+ if (isEqualRowOrCol(absPartIdxLB, absZorderCUIdxLB))
return m_encData->getPicCTU(m_cuAddr);
else
{
@@ -690,7 +685,7 @@
}
return NULL;
}
- blPartUnitIdx = g_rasterToZscan[absPartIdxLB + s_numPartInCUSize * 2 - 1];
+ blPartUnitIdx = g_rasterToZscan[absPartIdxLB + RASTER_SIZE + s_numPartInCUSize - 1];
return m_cuLeft;
}
@@ -704,15 +699,15 @@
uint32_t absPartIdxLB = g_zscanToRaster[curPartUnitIdx];
- if (lessThanRow(absPartIdxLB, s_numPartInCUSize - partUnitOffset, s_numPartInCUSize))
+ if (lessThanRow(absPartIdxLB, s_numPartInCUSize - partUnitOffset))
{
- if (!isZeroCol(absPartIdxLB, s_numPartInCUSize))
+ if (!isZeroCol(absPartIdxLB))
{
- if (curPartUnitIdx > g_rasterToZscan[absPartIdxLB + partUnitOffset * s_numPartInCUSize - 1])
+ if (curPartUnitIdx > g_rasterToZscan[absPartIdxLB + (partUnitOffset << LOG2_RASTER_SIZE) - 1])
{
- uint32_t absZorderCUIdxLB = g_zscanToRaster[m_absIdxInCTU] + ((1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE)) - 1) * s_numPartInCUSize;
- blPartUnitIdx = g_rasterToZscan[absPartIdxLB + partUnitOffset * s_numPartInCUSize - 1];
- if (isEqualRowOrCol(absPartIdxLB, absZorderCUIdxLB, s_numPartInCUSize))
+ uint32_t absZorderCUIdxLB = g_zscanToRaster[m_absIdxInCTU] + (((1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE)) - 1) << LOG2_RASTER_SIZE);
+ blPartUnitIdx = g_rasterToZscan[absPartIdxLB + (partUnitOffset << LOG2_RASTER_SIZE) - 1];
+ if (isEqualRowOrCol(absPartIdxLB, absZorderCUIdxLB))
return m_encData->getPicCTU(m_cuAddr);
else
{
@@ -722,7 +717,7 @@
}
return NULL;
}
- blPartUnitIdx = g_rasterToZscan[absPartIdxLB + (1 + partUnitOffset) * s_numPartInCUSize - 1];
+ blPartUnitIdx = g_rasterToZscan[absPartIdxLB + (partUnitOffset << LOG2_RASTER_SIZE) + s_numPartInCUSize - 1];
return m_cuLeft;
}
@@ -736,15 +731,15 @@
uint32_t absPartIdxRT = g_zscanToRaster[curPartUnitIdx];
- if (lessThanCol(absPartIdxRT, s_numPartInCUSize - partUnitOffset, s_numPartInCUSize))
+ if (lessThanCol(absPartIdxRT, s_numPartInCUSize - partUnitOffset))
{
- if (!isZeroRow(absPartIdxRT, s_numPartInCUSize))
+ if (!isZeroRow(absPartIdxRT))
{
- if (curPartUnitIdx > g_rasterToZscan[absPartIdxRT - s_numPartInCUSize + partUnitOffset])
+ if (curPartUnitIdx > g_rasterToZscan[absPartIdxRT - RASTER_SIZE + partUnitOffset])
{
uint32_t absZorderCUIdx = g_zscanToRaster[m_absIdxInCTU] + (1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE)) - 1;
- arPartUnitIdx = g_rasterToZscan[absPartIdxRT - s_numPartInCUSize + partUnitOffset];
- if (isEqualRowOrCol(absPartIdxRT, absZorderCUIdx, s_numPartInCUSize))
+ arPartUnitIdx = g_rasterToZscan[absPartIdxRT - RASTER_SIZE + partUnitOffset];
+ if (isEqualRowOrCol(absPartIdxRT, absZorderCUIdx))
return m_encData->getPicCTU(m_cuAddr);
else
{
@@ -754,14 +749,14 @@
}
return NULL;
}
- arPartUnitIdx = g_rasterToZscan[absPartIdxRT + NUM_4x4_PARTITIONS - s_numPartInCUSize + partUnitOffset];
+ arPartUnitIdx = g_rasterToZscan[absPartIdxRT + ((s_numPartInCUSize - 1) << LOG2_RASTER_SIZE) + partUnitOffset];
return m_cuAbove;
}
- if (!isZeroRow(absPartIdxRT, s_numPartInCUSize))
+ if (!isZeroRow(absPartIdxRT))
return NULL;
- arPartUnitIdx = g_rasterToZscan[NUM_4x4_PARTITIONS - s_numPartInCUSize + partUnitOffset - 1];
+ arPartUnitIdx = g_rasterToZscan[((s_numPartInCUSize - 1) << LOG2_RASTER_SIZE) + partUnitOffset - 1];
return m_cuAboveRight;
}
@@ -772,7 +767,7 @@
uint32_t absRorderQpMinCUIdx = g_zscanToRaster[absZorderQpMinCUIdx];
// check for left CTU boundary
- if (isZeroCol(absRorderQpMinCUIdx, s_numPartInCUSize))
+ if (isZeroCol(absRorderQpMinCUIdx))
return NULL;
// get index of left-CU relative to top-left corner of current quantization group
@@ -789,11 +784,11 @@
uint32_t absRorderQpMinCUIdx = g_zscanToRaster[absZorderQpMinCUIdx];
// check for top CTU boundary
- if (isZeroRow(absRorderQpMinCUIdx, s_numPartInCUSize))
+ if (isZeroRow(absRorderQpMinCUIdx))
return NULL;
// get index of top-CU relative to top-left corner of current quantization group
- aPartUnitIdx = g_rasterToZscan[absRorderQpMinCUIdx - s_numPartInCUSize];
+ aPartUnitIdx = g_rasterToZscan[absRorderQpMinCUIdx - RASTER_SIZE];
// return pointer to current CTU
return m_encData->getPicCTU(m_cuAddr);
@@ -1315,7 +1310,7 @@
uint32_t CUData::deriveLeftBottomIdx(uint32_t puIdx) const
{
uint32_t outPartIdxLB;
- outPartIdxLB = g_rasterToZscan[g_zscanToRaster[m_absIdxInCTU] + ((1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE - 1)) - 1) * s_numPartInCUSize];
+ outPartIdxLB = g_rasterToZscan[g_zscanToRaster[m_absIdxInCTU] + (((1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE - 1)) - 1) << LOG2_RASTER_SIZE)];
switch (m_partSize[0])
{
@@ -1355,7 +1350,7 @@
{
uint32_t outPartIdxRB;
outPartIdxRB = g_rasterToZscan[g_zscanToRaster[m_absIdxInCTU] +
- ((1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE - 1)) - 1) * s_numPartInCUSize +
+ (((1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE - 1)) - 1) << LOG2_RASTER_SIZE) +
(1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE)) - 1];
switch (m_partSize[0])
@@ -1558,19 +1553,19 @@
{
uint32_t absPartIdxRB = g_zscanToRaster[partIdxRB];
uint32_t numUnits = s_numPartInCUSize;
- bool bNotLastCol = lessThanCol(absPartIdxRB, numUnits - 1, numUnits); // is not at the last column of CTU
- bool bNotLastRow = lessThanRow(absPartIdxRB, numUnits - 1, numUnits); // is not at the last row of CTU
+ bool bNotLastCol = lessThanCol(absPartIdxRB, numUnits - 1); // is not at the last column of CTU
+ bool bNotLastRow = lessThanRow(absPartIdxRB, numUnits - 1); // is not at the last row of CTU
if (bNotLastCol && bNotLastRow)
{
- absPartAddr = g_rasterToZscan[absPartIdxRB + numUnits + 1];
+ absPartAddr = g_rasterToZscan[absPartIdxRB + RASTER_SIZE + 1];
ctuIdx = m_cuAddr;
}
else if (bNotLastCol)
- absPartAddr = g_rasterToZscan[(absPartIdxRB + numUnits + 1) & (numUnits - 1)];
+ absPartAddr = g_rasterToZscan[(absPartIdxRB + 1) & (numUnits - 1)];
else if (bNotLastRow)
{
- absPartAddr = g_rasterToZscan[absPartIdxRB + 1];
+ absPartAddr = g_rasterToZscan[absPartIdxRB + RASTER_SIZE - numUnits + 1];
ctuIdx = m_cuAddr + 1;
}
else // is the right bottom corner of CTU
@@ -1792,19 +1787,19 @@
{
uint32_t absPartIdxRB = g_zscanToRaster[partIdxRB];
uint32_t numUnits = s_numPartInCUSize;
- bool bNotLastCol = lessThanCol(absPartIdxRB, numUnits - 1, numUnits); // is not at the last column of CTU
- bool bNotLastRow = lessThanRow(absPartIdxRB, numUnits - 1, numUnits); // is not at the last row of CTU
+ bool bNotLastCol = lessThanCol(absPartIdxRB, numUnits - 1); // is not at the last column of CTU
+ bool bNotLastRow = lessThanRow(absPartIdxRB, numUnits - 1); // is not at the last row of CTU
if (bNotLastCol && bNotLastRow)
{
- absPartAddr = g_rasterToZscan[absPartIdxRB + numUnits + 1];
+ absPartAddr = g_rasterToZscan[absPartIdxRB + RASTER_SIZE + 1];
ctuIdx = m_cuAddr;
}
else if (bNotLastCol)
- absPartAddr = g_rasterToZscan[(absPartIdxRB + numUnits + 1) & (numUnits - 1)];
+ absPartAddr = g_rasterToZscan[(absPartIdxRB + 1) & (numUnits - 1)];
else if (bNotLastRow)
{
- absPartAddr = g_rasterToZscan[absPartIdxRB + 1];
+ absPartAddr = g_rasterToZscan[absPartIdxRB + RASTER_SIZE - numUnits + 1];
ctuIdx = m_cuAddr + 1;
}
else // is the right bottom corner of CTU
@@ -2008,7 +2003,7 @@
getPartIndexAndSize(puIdx, absPartIdx, puWidth, puHeight);
return g_rasterToZscan[g_zscanToRaster[m_absIdxInCTU + absPartIdx]
- + (puHeight >> (LOG2_UNIT_SIZE + 1)) * s_numPartInCUSize
+ + ((puHeight >> (LOG2_UNIT_SIZE + 1)) << LOG2_RASTER_SIZE)
+ (puWidth >> (LOG2_UNIT_SIZE + 1))];
}
diff -r a932b4366235 -r cf06a60ee646 source/common/deblock.cpp
--- a/source/common/deblock.cpp Mon Jul 04 21:25:59 2016 +0530
+++ b/source/common/deblock.cpp Tue Jul 05 20:54:19 2016 +0900
@@ -90,7 +90,7 @@
uint32_t numUnits = 1 << (cuGeom.log2CUSize - LOG2_UNIT_SIZE);
setEdgefilterPU(cu, absPartIdx, dir, blockStrength, numUnits);
setEdgefilterTU(cu, absPartIdx, 0, dir, blockStrength);
- setEdgefilterMultiple(cu, absPartIdx, dir, 0, bsCuEdge(cu, absPartIdx, dir), blockStrength, numUnits);
+ setEdgefilterMultiple(absPartIdx, dir, 0, bsCuEdge(cu, absPartIdx, dir), blockStrength, numUnits);
uint32_t numParts = cuGeom.numPartitions;
for (uint32_t partIdx = absPartIdx; partIdx < absPartIdx + numParts; partIdx++)
@@ -114,22 +114,20 @@
}
}
-static inline uint32_t calcBsIdx(const CUData* cu, uint32_t absPartIdx, int32_t dir, int32_t edgeIdx, int32_t baseUnitIdx)
+static inline uint32_t calcBsIdx(uint32_t absPartIdx, int32_t dir, int32_t edgeIdx, int32_t baseUnitIdx)
{
- uint32_t numUnits = cu->m_slice->m_sps->numPartInCUSize;
-
if (dir)
- return g_rasterToZscan[g_zscanToRaster[absPartIdx] + edgeIdx * numUnits + baseUnitIdx];
+ return g_rasterToZscan[g_zscanToRaster[absPartIdx] + (edgeIdx << LOG2_RASTER_SIZE) + baseUnitIdx];
else
- return g_rasterToZscan[g_zscanToRaster[absPartIdx] + baseUnitIdx * numUnits + edgeIdx];
+ return g_rasterToZscan[g_zscanToRaster[absPartIdx] + (baseUnitIdx << LOG2_RASTER_SIZE) + edgeIdx];
}
-void Deblock::setEdgefilterMultiple(const CUData* cu, uint32_t scanIdx, int32_t dir, int32_t edgeIdx, uint8_t value, uint8_t blockStrength[], uint32_t numUnits)
+void Deblock::setEdgefilterMultiple(uint32_t scanIdx, int32_t dir, int32_t edgeIdx, uint8_t value, uint8_t blockStrength[], uint32_t numUnits)
{
X265_CHECK(numUnits > 0, "numUnits edge filter check\n");
for (uint32_t i = 0; i < numUnits; i++)
{
- const uint32_t bsidx = calcBsIdx(cu, scanIdx, dir, edgeIdx, i);
+ const uint32_t bsidx = calcBsIdx(scanIdx, dir, edgeIdx, i);
blockStrength[bsidx] = value;
}
}
@@ -145,8 +143,8 @@
return;
}
- uint32_t numUnits = 1 << (log2TrSize - LOG2_UNIT_SIZE);
- setEdgefilterMultiple(cu, absPartIdx, dir, 0, 2, blockStrength, numUnits);
+ uint32_t numUnits = 1 << (log2TrSize - LOG2_UNIT_SIZE);
+ setEdgefilterMultiple(absPartIdx, dir, 0, 2, blockStrength, numUnits);
}
void Deblock::setEdgefilterPU(const CUData* cu, uint32_t absPartIdx, int32_t dir, uint8_t blockStrength[], uint32_t numUnits)
@@ -158,30 +156,30 @@
{
case SIZE_2NxN:
if (EDGE_HOR == dir)
- setEdgefilterMultiple(cu, absPartIdx, dir, hNumUnits, 1, blockStrength, numUnits);
+ setEdgefilterMultiple(absPartIdx, dir, hNumUnits, 1, blockStrength, numUnits);
break;
case SIZE_Nx2N:
if (EDGE_VER == dir)
- setEdgefilterMultiple(cu, absPartIdx, dir, hNumUnits, 1, blockStrength, numUnits);
+ setEdgefilterMultiple(absPartIdx, dir, hNumUnits, 1, blockStrength, numUnits);
break;
case SIZE_NxN:
- setEdgefilterMultiple(cu, absPartIdx, dir, hNumUnits, 1, blockStrength, numUnits);
+ setEdgefilterMultiple(absPartIdx, dir, hNumUnits, 1, blockStrength, numUnits);
break;
case SIZE_2NxnU:
if (EDGE_HOR == dir)
- setEdgefilterMultiple(cu, absPartIdx, dir, qNumUnits, 1, blockStrength, numUnits);
+ setEdgefilterMultiple(absPartIdx, dir, qNumUnits, 1, blockStrength, numUnits);
break;
case SIZE_nLx2N:
if (EDGE_VER == dir)
- setEdgefilterMultiple(cu, absPartIdx, dir, qNumUnits, 1, blockStrength, numUnits);
+ setEdgefilterMultiple(absPartIdx, dir, qNumUnits, 1, blockStrength, numUnits);
break;
case SIZE_2NxnD:
if (EDGE_HOR == dir)
- setEdgefilterMultiple(cu, absPartIdx, dir, numUnits - qNumUnits, 1, blockStrength, numUnits);
+ setEdgefilterMultiple(absPartIdx, dir, numUnits - qNumUnits, 1, blockStrength, numUnits);
break;
case SIZE_nRx2N:
if (EDGE_VER == dir)
- setEdgefilterMultiple(cu, absPartIdx, dir, numUnits - qNumUnits, 1, blockStrength, numUnits);
+ setEdgefilterMultiple(absPartIdx, dir, numUnits - qNumUnits, 1, blockStrength, numUnits);
break;
case SIZE_2Nx2N:
@@ -350,7 +348,7 @@
uint32_t numUnits = cuQ->m_slice->m_sps->numPartInCUSize >> depth;
for (uint32_t idx = 0; idx < numUnits; idx++)
{
- uint32_t partQ = calcBsIdx(cuQ, absPartIdx, dir, edge, idx);
+ uint32_t partQ = calcBsIdx(absPartIdx, dir, edge, idx);
uint32_t bs = blockStrength[partQ];
if (!bs)
@@ -461,7 +459,7 @@
uint32_t numUnits = cuQ->m_slice->m_sps->numPartInCUSize >> (depth + chromaShift);
for (uint32_t idx = 0; idx < numUnits; idx++)
{
- uint32_t partQ = calcBsIdx(cuQ, absPartIdx, dir, edge, idx << chromaShift);
+ uint32_t partQ = calcBsIdx(absPartIdx, dir, edge, idx << chromaShift);
uint32_t bs = blockStrength[partQ];
if (bs <= 1)
diff -r a932b4366235 -r cf06a60ee646 source/common/deblock.h
--- a/source/common/deblock.h Mon Jul 04 21:25:59 2016 +0530
+++ b/source/common/deblock.h Tue Jul 05 20:54:19 2016 +0900
@@ -48,7 +48,7 @@
// set filtering functions
static void setEdgefilterTU(const CUData* cu, uint32_t absPartIdx, uint32_t tuDepth, int32_t dir, uint8_t blockStrength[]);
static void setEdgefilterPU(const CUData* cu, uint32_t absPartIdx, int32_t dir, uint8_t blockStrength[], uint32_t numUnits);
- static void setEdgefilterMultiple(const CUData* cu, uint32_t absPartIdx, int32_t dir, int32_t edgeIdx, uint8_t value, uint8_t blockStrength[], uint32_t numUnits);
+ static void setEdgefilterMultiple(uint32_t absPartIdx, int32_t dir, int32_t edgeIdx, uint8_t value, uint8_t blockStrength[], uint32_t numUnits);
// get filtering functions
static uint8_t getBoundaryStrength(const CUData* cuQ, int32_t dir, uint32_t partQ, const uint8_t blockStrength[]);
diff -r a932b4366235 -r cf06a60ee646 source/common/param.cpp
--- a/source/common/param.cpp Mon Jul 04 21:25:59 2016 +0530
+++ b/source/common/param.cpp Tue Jul 05 20:54:19 2016 +0900
@@ -1258,11 +1258,6 @@
// compute actual CU depth with respect to config depth and max transform size
g_maxCUDepth = maxLog2CUSize - minLog2CUSize;
g_unitSizeDepth = maxLog2CUSize - LOG2_UNIT_SIZE;
-
- // initialize partition order
- uint32_t* tmp = &g_zscanToRaster[0];
- initZscanToRaster(g_unitSizeDepth, 1, 0, tmp);
- initRasterToZscan(g_unitSizeDepth);
}
return 0;
}
diff -r a932b4366235 -r cf06a60ee646 source/common/predict.cpp
--- a/source/common/predict.cpp Mon Jul 04 21:25:59 2016 +0530
+++ b/source/common/predict.cpp Tue Jul 05 20:54:19 2016 +0900
@@ -671,17 +671,14 @@
int numIntraNeighbor;
bool* bNeighborFlags = intraNeighbors->bNeighborFlags;
- uint32_t numPartInWidth = 1 << (cu.m_log2CUSize[0] - LOG2_UNIT_SIZE - tuDepth);
- uint32_t partIdxLT = cu.m_absIdxInCTU + absPartIdx;
- uint32_t partIdxRT = g_rasterToZscan[g_zscanToRaster[partIdxLT] + numPartInWidth - 1];
-
uint32_t tuSize = 1 << log2TrSize;
int tuWidthInUnits = tuSize >> log2UnitWidth;
int tuHeightInUnits = tuSize >> log2UnitHeight;
int aboveUnits = tuWidthInUnits << 1;
int leftUnits = tuHeightInUnits << 1;
- int partIdxStride = cu.m_slice->m_sps->numPartInCUSize;
- uint32_t partIdxLB = g_rasterToZscan[g_zscanToRaster[partIdxLT] + ((tuHeightInUnits - 1) * partIdxStride)];
+ uint32_t partIdxLT = cu.m_absIdxInCTU + absPartIdx;
+ uint32_t partIdxRT = g_rasterToZscan[g_zscanToRaster[partIdxLT] + tuWidthInUnits - 1];
+ uint32_t partIdxLB = g_rasterToZscan[g_zscanToRaster[partIdxLT] + ((tuHeightInUnits - 1) << LOG2_RASTER_SIZE)];
if (cu.m_slice->isIntra() || !cu.m_slice->m_pps->bConstrainedIntraPred)
{
@@ -910,7 +907,7 @@
{
const uint32_t rasterPartBegin = g_zscanToRaster[partIdxLT];
const uint32_t rasterPartEnd = g_zscanToRaster[partIdxLB];
- const uint32_t idxStep = cu.m_slice->m_sps->numPartInCUSize;
+ const uint32_t idxStep = RASTER_SIZE;
int numIntra = 0;
for (uint32_t rasterPart = rasterPartBegin; rasterPart <= rasterPartEnd; rasterPart += idxStep, bValidFlags--) // opposite direction
More information about the x265-devel
mailing list