[x265] [PATCH 1 of 3] rename variable g_maxFullDepth to g_unitSizeDepth, NUM_CU_PARTITIONS to NUM_4x4_PARTITIONS
Steve Borho
steve at borho.org
Tue Feb 17 06:43:51 CET 2015
On 02/16, santhoshini at multicorewareinc.com wrote:
> # HG changeset patch
> # User Santhoshini Sekar<santhoshini at multicorewareinc.com>
> # Date 1424077099 -19800
> # Mon Feb 16 14:28:19 2015 +0530
> # Node ID 59466f1455ce52920eb642cf06db4b4de8d8ff10
> # Parent 2495fbd5792104c96c4ca5faf18807cc45a35da0
> rename variable g_maxFullDepth to g_unitSizeDepth, NUM_CU_PARTITIONS to NUM_4x4_PARTITIONS
> for better clarity
this generally looks ok, can probably be queued independently of the
other changes
> diff -r 2495fbd57921 -r 59466f1455ce source/common/common.h
> --- a/source/common/common.h Mon Feb 16 16:16:04 2015 +0530
> +++ b/source/common/common.h Mon Feb 16 14:28:19 2015 +0530
> @@ -258,7 +258,7 @@
> #define UNIT_SIZE (1 << LOG2_UNIT_SIZE) // unit size of CU partition
>
> #define MAX_NUM_PARTITIONS 256
> -#define NUM_CU_PARTITIONS (1U << (g_maxFullDepth << 1))
> +#define NUM_4x4_PARTITIONS (1U << (g_unitSizeDepth << 1)) // number of 4x4 units in max CU size
>
> #define MIN_PU_SIZE 4
> #define MIN_TU_SIZE 4
> diff -r 2495fbd57921 -r 59466f1455ce source/common/constants.cpp
> --- a/source/common/constants.cpp Mon Feb 16 16:16:04 2015 +0530
> +++ b/source/common/constants.cpp Mon Feb 16 14:28:19 2015 +0530
> @@ -121,7 +121,7 @@
>
> uint32_t g_maxLog2CUSize = MAX_LOG2_CU_SIZE;
> uint32_t g_maxCUSize = MAX_CU_SIZE;
> -uint32_t g_maxFullDepth = NUM_FULL_DEPTH - 1;
> +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, };
> diff -r 2495fbd57921 -r 59466f1455ce source/common/constants.h
> --- a/source/common/constants.h Mon Feb 16 16:16:04 2015 +0530
> +++ b/source/common/constants.h Mon Feb 16 14:28:19 2015 +0530
> @@ -55,7 +55,7 @@
> extern uint32_t g_maxLog2CUSize;
> extern uint32_t g_maxCUSize;
> extern uint32_t g_maxCUDepth;
> -extern uint32_t g_maxFullDepth;
> +extern uint32_t g_unitSizeDepth; // Depth at which 4x4 unit occurs from max CU size
>
> extern const int16_t g_t4[4][4];
> extern const int16_t g_t8[8][8];
> diff -r 2495fbd57921 -r 59466f1455ce source/common/cudata.cpp
> --- a/source/common/cudata.cpp Mon Feb 16 16:16:04 2015 +0530
> +++ b/source/common/cudata.cpp Mon Feb 16 14:28:19 2015 +0530
> @@ -159,11 +159,11 @@
> m_chromaFormat = csp;
> m_hChromaShift = CHROMA_H_SHIFT(csp);
> m_vChromaShift = CHROMA_V_SHIFT(csp);
> - m_numPartitions = NUM_CU_PARTITIONS >> (depth * 2);
> + m_numPartitions = NUM_4x4_PARTITIONS >> (depth * 2);
>
> if (!s_partSet[0])
> {
> - s_numPartInCUSize = 1 << g_maxFullDepth;
> + s_numPartInCUSize = 1 << g_unitSizeDepth;
> switch (g_maxLog2CUSize)
> {
> case 6:
> @@ -272,7 +272,7 @@
> m_cuPelX = (cuAddr % m_slice->m_sps->numCuInWidth) << g_maxLog2CUSize;
> m_cuPelY = (cuAddr / m_slice->m_sps->numCuInWidth) << g_maxLog2CUSize;
> m_absIdxInCTU = 0;
> - m_numPartitions = NUM_CU_PARTITIONS;
> + m_numPartitions = NUM_4x4_PARTITIONS;
>
> /* sequential memsets */
> m_partSet((uint8_t*)m_qp, (uint8_t)qp);
> @@ -559,7 +559,7 @@
> return this;
> }
>
> - aPartUnitIdx = g_rasterToZscan[absPartIdx + NUM_CU_PARTITIONS - s_numPartInCUSize];
> + aPartUnitIdx = g_rasterToZscan[absPartIdx + NUM_4x4_PARTITIONS - s_numPartInCUSize];
> return m_cuAbove;
> }
>
> @@ -581,7 +581,7 @@
> return this;
> }
> }
> - alPartUnitIdx = g_rasterToZscan[absPartIdx + NUM_CU_PARTITIONS - s_numPartInCUSize - 1];
> + alPartUnitIdx = g_rasterToZscan[absPartIdx + NUM_4x4_PARTITIONS - s_numPartInCUSize - 1];
> return m_cuAbove;
> }
>
> @@ -591,7 +591,7 @@
> return m_cuLeft;
> }
>
> - alPartUnitIdx = g_rasterToZscan[NUM_CU_PARTITIONS - 1];
> + alPartUnitIdx = g_rasterToZscan[NUM_4x4_PARTITIONS - 1];
> return m_cuAboveLeft;
> }
>
> @@ -620,14 +620,14 @@
> }
> return NULL;
> }
> - arPartUnitIdx = g_rasterToZscan[absPartIdxRT + NUM_CU_PARTITIONS - s_numPartInCUSize + 1];
> + arPartUnitIdx = g_rasterToZscan[absPartIdxRT + NUM_4x4_PARTITIONS - s_numPartInCUSize + 1];
> return m_cuAbove;
> }
>
> if (!isZeroRow(absPartIdxRT, s_numPartInCUSize))
> return NULL;
>
> - arPartUnitIdx = g_rasterToZscan[NUM_CU_PARTITIONS - s_numPartInCUSize];
> + arPartUnitIdx = g_rasterToZscan[NUM_4x4_PARTITIONS - s_numPartInCUSize];
> return m_cuAboveRight;
> }
>
> @@ -720,21 +720,21 @@
> }
> return NULL;
> }
> - arPartUnitIdx = g_rasterToZscan[absPartIdxRT + NUM_CU_PARTITIONS - s_numPartInCUSize + partUnitOffset];
> + arPartUnitIdx = g_rasterToZscan[absPartIdxRT + NUM_4x4_PARTITIONS - s_numPartInCUSize + partUnitOffset];
> return m_cuAbove;
> }
>
> if (!isZeroRow(absPartIdxRT, s_numPartInCUSize))
> return NULL;
>
> - arPartUnitIdx = g_rasterToZscan[NUM_CU_PARTITIONS - s_numPartInCUSize + partUnitOffset - 1];
> + arPartUnitIdx = g_rasterToZscan[NUM_4x4_PARTITIONS - s_numPartInCUSize + partUnitOffset - 1];
> return m_cuAboveRight;
> }
>
> /* Get left QpMinCu */
> const CUData* CUData::getQpMinCuLeft(uint32_t& lPartUnitIdx, uint32_t curAbsIdxInCTU) const
> {
> - uint32_t absZorderQpMinCUIdx = curAbsIdxInCTU & (0xFF << (g_maxFullDepth - m_slice->m_pps->maxCuDQPDepth) * 2);
> + uint32_t absZorderQpMinCUIdx = curAbsIdxInCTU & (0xFF << (g_unitSizeDepth - m_slice->m_pps->maxCuDQPDepth) * 2);
> uint32_t absRorderQpMinCUIdx = g_zscanToRaster[absZorderQpMinCUIdx];
>
> // check for left CTU boundary
> @@ -751,7 +751,7 @@
> /* Get above QpMinCu */
> const CUData* CUData::getQpMinCuAbove(uint32_t& aPartUnitIdx, uint32_t curAbsIdxInCTU) const
> {
> - uint32_t absZorderQpMinCUIdx = curAbsIdxInCTU & (0xFF << (g_maxFullDepth - m_slice->m_pps->maxCuDQPDepth) * 2);
> + uint32_t absZorderQpMinCUIdx = curAbsIdxInCTU & (0xFF << (g_unitSizeDepth - m_slice->m_pps->maxCuDQPDepth) * 2);
> uint32_t absRorderQpMinCUIdx = g_zscanToRaster[absZorderQpMinCUIdx];
>
> // check for top CTU boundary
> @@ -790,7 +790,7 @@
>
> int8_t CUData::getLastCodedQP(uint32_t absPartIdx) const
> {
> - uint32_t quPartIdxMask = 0xFF << (g_maxFullDepth - m_slice->m_pps->maxCuDQPDepth) * 2;
> + uint32_t quPartIdxMask = 0xFF << (g_unitSizeDepth - m_slice->m_pps->maxCuDQPDepth) * 2;
> int lastValidPartIdx = getLastValidPartIdx(absPartIdx & quPartIdxMask);
>
> if (lastValidPartIdx >= 0)
> @@ -800,7 +800,7 @@
> if (m_absIdxInCTU)
> return m_encData->getPicCTU(m_cuAddr)->getLastCodedQP(m_absIdxInCTU);
> else if (m_cuAddr > 0 && !(m_slice->m_pps->bEntropyCodingSyncEnabled && !(m_cuAddr % m_slice->m_sps->numCuInWidth)))
> - return m_encData->getPicCTU(m_cuAddr - 1)->getLastCodedQP(NUM_CU_PARTITIONS);
> + return m_encData->getPicCTU(m_cuAddr - 1)->getLastCodedQP(NUM_4x4_PARTITIONS);
> else
> return (int8_t)m_slice->m_sliceQp;
> }
> @@ -932,7 +932,7 @@
>
> bool CUData::setQPSubCUs(int8_t qp, uint32_t absPartIdx, uint32_t depth)
> {
> - uint32_t curPartNumb = NUM_CU_PARTITIONS >> (depth << 1);
> + uint32_t curPartNumb = NUM_4x4_PARTITIONS >> (depth << 1);
> uint32_t curPartNumQ = curPartNumb >> 2;
>
> if (m_cuDepth[absPartIdx] > depth)
> @@ -2095,7 +2095,7 @@
> cu->log2CUSize = log2CUSize;
> cu->childOffset = childIdx - cuIdx;
> cu->encodeIdx = g_depthScanIdx[yOffset][xOffset] * 4;
> - cu->numPartitions = (NUM_CU_PARTITIONS >> ((g_maxLog2CUSize - cu->log2CUSize) * 2));
> + cu->numPartitions = (NUM_4x4_PARTITIONS >> ((g_maxLog2CUSize - cu->log2CUSize) * 2));
> cu->depth = g_log2Size[maxCUSize] - log2CUSize;
>
> cu->flags = 0;
> diff -r 2495fbd57921 -r 59466f1455ce source/common/cudata.h
> --- a/source/common/cudata.h Mon Feb 16 16:16:04 2015 +0530
> +++ b/source/common/cudata.h Mon Feb 16 14:28:19 2015 +0530
> @@ -213,7 +213,7 @@
> void getAllowedChromaDir(uint32_t absPartIdx, uint32_t* modeList) const;
> int getIntraDirLumaPredictor(uint32_t absPartIdx, uint32_t* intraDirPred) const;
>
> - uint32_t getSCUAddr() const { return (m_cuAddr << g_maxFullDepth * 2) + m_absIdxInCTU; }
> + uint32_t getSCUAddr() const { return (m_cuAddr << g_unitSizeDepth * 2) + m_absIdxInCTU; }
> uint32_t getCtxSplitFlag(uint32_t absPartIdx, uint32_t depth) const;
> uint32_t getCtxSkipFlag(uint32_t absPartIdx) const;
> ScanType getCoefScanIdx(uint32_t absPartIdx, uint32_t log2TrSize, bool bIsLuma, bool bIsIntra) const;
> @@ -278,7 +278,7 @@
>
> bool create(uint32_t depth, uint32_t csp, uint32_t numInstances)
> {
> - uint32_t numPartition = NUM_CU_PARTITIONS >> (depth * 2);
> + uint32_t numPartition = NUM_4x4_PARTITIONS >> (depth * 2);
> uint32_t cuSize = g_maxCUSize >> depth;
> uint32_t sizeL = cuSize * cuSize;
> uint32_t sizeC = sizeL >> (CHROMA_H_SHIFT(csp) + CHROMA_V_SHIFT(csp));
> diff -r 2495fbd57921 -r 59466f1455ce source/common/param.cpp
> --- a/source/common/param.cpp Mon Feb 16 16:16:04 2015 +0530
> +++ b/source/common/param.cpp Mon Feb 16 14:28:19 2015 +0530
> @@ -1174,12 +1174,12 @@
>
> // compute actual CU depth with respect to config depth and max transform size
> g_maxCUDepth = maxLog2CUSize - MIN_LOG2_CU_SIZE;
> - g_maxFullDepth = maxLog2CUSize - LOG2_UNIT_SIZE;
> + g_unitSizeDepth = maxLog2CUSize - LOG2_UNIT_SIZE;
>
> // initialize partition order
> uint32_t* tmp = &g_zscanToRaster[0];
> - initZscanToRaster(g_maxFullDepth, 1, 0, tmp);
> - initRasterToZscan(g_maxFullDepth);
> + initZscanToRaster(g_unitSizeDepth, 1, 0, tmp);
> + initRasterToZscan(g_unitSizeDepth);
> }
> return 0;
> }
> diff -r 2495fbd57921 -r 59466f1455ce source/common/picyuv.cpp
> --- a/source/common/picyuv.cpp Mon Feb 16 16:16:04 2015 +0530
> +++ b/source/common/picyuv.cpp Mon Feb 16 14:28:19 2015 +0530
> @@ -84,7 +84,7 @@
> * allocated by the same encoder. */
> bool PicYuv::createOffsets(const SPS& sps)
> {
> - uint32_t numPartitions = 1 << (g_maxFullDepth * 2);
> + uint32_t numPartitions = 1 << (g_unitSizeDepth * 2);
> CHECKED_MALLOC(m_cuOffsetY, intptr_t, sps.numCuInWidth * sps.numCuInHeight);
> CHECKED_MALLOC(m_cuOffsetC, intptr_t, sps.numCuInWidth * sps.numCuInHeight);
> for (uint32_t cuRow = 0; cuRow < sps.numCuInHeight; cuRow++)
> diff -r 2495fbd57921 -r 59466f1455ce source/common/slice.cpp
> --- a/source/common/slice.cpp Mon Feb 16 16:16:04 2015 +0530
> +++ b/source/common/slice.cpp Mon Feb 16 14:28:19 2015 +0530
> @@ -183,8 +183,8 @@
> uint32_t Slice::realEndAddress(uint32_t endCUAddr) const
> {
> // Calculate end address
> - uint32_t internalAddress = (endCUAddr - 1) % NUM_CU_PARTITIONS;
> - uint32_t externalAddress = (endCUAddr - 1) / NUM_CU_PARTITIONS;
> + uint32_t internalAddress = (endCUAddr - 1) % NUM_4x4_PARTITIONS;
> + uint32_t externalAddress = (endCUAddr - 1) / NUM_4x4_PARTITIONS;
> uint32_t xmax = m_sps->picWidthInLumaSamples - (externalAddress % m_sps->numCuInWidth) * g_maxCUSize;
> uint32_t ymax = m_sps->picHeightInLumaSamples - (externalAddress / m_sps->numCuInWidth) * g_maxCUSize;
>
> @@ -192,13 +192,13 @@
> internalAddress--;
>
> internalAddress++;
> - if (internalAddress == NUM_CU_PARTITIONS)
> + if (internalAddress == NUM_4x4_PARTITIONS)
> {
> internalAddress = 0;
> externalAddress++;
> }
>
> - return externalAddress * NUM_CU_PARTITIONS + internalAddress;
> + return externalAddress * NUM_4x4_PARTITIONS + internalAddress;
> }
>
>
> diff -r 2495fbd57921 -r 59466f1455ce source/encoder/api.cpp
> --- a/source/encoder/api.cpp Mon Feb 16 16:16:04 2015 +0530
> +++ b/source/encoder/api.cpp Mon Feb 16 14:28:19 2015 +0530
> @@ -206,7 +206,7 @@
>
> uint32_t numCUsInFrame = widthInCU * heightInCU;
> pic->analysisData.numCUsInFrame = numCUsInFrame;
> - pic->analysisData.numPartitions = NUM_CU_PARTITIONS;
> + pic->analysisData.numPartitions = NUM_4x4_PARTITIONS;
> }
> }
>
> diff -r 2495fbd57921 -r 59466f1455ce source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp Mon Feb 16 16:16:04 2015 +0530
> +++ b/source/encoder/encoder.cpp Mon Feb 16 14:28:19 2015 +0530
> @@ -637,7 +637,7 @@
> slice->m_sps = &m_sps;
> slice->m_pps = &m_pps;
> slice->m_maxNumMergeCand = m_param->maxNumMergeCand;
> - slice->m_endCUAddr = slice->realEndAddress(m_sps.numCUsInFrame * NUM_CU_PARTITIONS);
> + slice->m_endCUAddr = slice->realEndAddress(m_sps.numCUsInFrame * NUM_4x4_PARTITIONS);
> frameEnc->m_reconPic->m_cuOffsetC = m_cuOffsetC;
> frameEnc->m_reconPic->m_cuOffsetY = m_cuOffsetY;
> frameEnc->m_reconPic->m_buOffsetC = m_buOffsetC;
> @@ -667,7 +667,7 @@
>
> uint32_t numCUsInFrame = widthInCU * heightInCU;
> analysis->numCUsInFrame = numCUsInFrame;
> - analysis->numPartitions = NUM_CU_PARTITIONS;
> + analysis->numPartitions = NUM_4x4_PARTITIONS;
> allocAnalysis(analysis);
> }
>
> @@ -1440,8 +1440,8 @@
> sps->numCuInWidth = (m_param->sourceWidth + g_maxCUSize - 1) / g_maxCUSize;
> sps->numCuInHeight = (m_param->sourceHeight + g_maxCUSize - 1) / g_maxCUSize;
> sps->numCUsInFrame = sps->numCuInWidth * sps->numCuInHeight;
> - sps->numPartitions = NUM_CU_PARTITIONS;
> - sps->numPartInCUSize = 1 << g_maxFullDepth;
> + sps->numPartitions = NUM_4x4_PARTITIONS;
> + sps->numPartInCUSize = 1 << g_unitSizeDepth;
>
> sps->log2MinCodingBlockSize = g_maxLog2CUSize - g_maxCUDepth;
> sps->log2DiffMaxMinCodingBlockSize = g_maxCUDepth;
> diff -r 2495fbd57921 -r 59466f1455ce source/encoder/entropy.cpp
> --- a/source/encoder/entropy.cpp Mon Feb 16 16:16:04 2015 +0530
> +++ b/source/encoder/entropy.cpp Mon Feb 16 14:28:19 2015 +0530
> @@ -671,7 +671,7 @@
> {
> // Encode slice finish
> bool bTerminateSlice = false;
> - if (cuAddr + (NUM_CU_PARTITIONS >> (depth << 1)) == realEndAddress)
> + if (cuAddr + (NUM_4x4_PARTITIONS >> (depth << 1)) == realEndAddress)
> bTerminateSlice = true;
>
> // The 1-terminating bit is added to all streams, so don't add it here when it's 1.
> @@ -855,7 +855,7 @@
> PartSize partSize = (PartSize)cu.m_partSize[absPartIdx];
> uint32_t numPU = (partSize == SIZE_2Nx2N ? 1 : (partSize == SIZE_NxN ? 4 : 2));
> uint32_t depth = cu.m_cuDepth[absPartIdx];
> - uint32_t puOffset = (g_puOffset[uint32_t(partSize)] << (g_maxFullDepth - depth) * 2) >> 4;
> + uint32_t puOffset = (g_puOffset[uint32_t(partSize)] << (g_unitSizeDepth - depth) * 2) >> 4;
>
> for (uint32_t puIdx = 0, subPartIdx = absPartIdx; puIdx < numPU; puIdx++, subPartIdx += puOffset)
> {
> diff -r 2495fbd57921 -r 59466f1455ce source/encoder/frameencoder.cpp
> --- a/source/encoder/frameencoder.cpp Mon Feb 16 16:16:04 2015 +0530
> +++ b/source/encoder/frameencoder.cpp Mon Feb 16 14:28:19 2015 +0530
> @@ -538,7 +538,7 @@
> {
> Slice* slice = m_frame->m_encData->m_slice;
> const uint32_t widthInLCUs = slice->m_sps->numCuInWidth;
> - const uint32_t lastCUAddr = (slice->m_endCUAddr + NUM_CU_PARTITIONS - 1) / NUM_CU_PARTITIONS;
> + const uint32_t lastCUAddr = (slice->m_endCUAddr + NUM_4x4_PARTITIONS - 1) / NUM_4x4_PARTITIONS;
> const uint32_t numSubstreams = m_param->bEnableWavefront ? slice->m_sps->numCuInHeight : 1;
>
> SAOParam* saoParam = slice->m_sps->bUseSAO ? m_frame->m_encData->m_saoParam : NULL;
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
--
Steve Borho
More information about the x265-devel
mailing list