注:问号以及未注释部分 会在x265-1.9版本内更新

/****************************************************************************** Copyright (C) 2015 x265 project** Authors: Steve Borho <steve@borho.org>** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation; either version 2 of the License, or* (at your option) any later version.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the* GNU General Public License for more details.** You should have received a copy of the GNU General Public License* along with this program; if not, write to the Free Software* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.** This program is also available under a commercial proprietary license.* For more information, contact us at license @ x265.com.*****************************************************************************/#ifndef X265_CUDATA_H
#define X265_CUDATA_H#include "common.h"
#include "slice.h"
#include "mv.h"namespace X265_NS {
// private namespaceclass FrameData;
class Slice;
struct TUEntropyCodingParameters;
struct CUDataMemPool;enum PartSize//PU划分方式
{SIZE_2Nx2N, // symmetric motion partition,  2Nx2NSIZE_2NxN,  // symmetric motion partition,  2Nx NSIZE_Nx2N,  // symmetric motion partition,   Nx2NSIZE_NxN,   // symmetric motion partition,   Nx NSIZE_2NxnU, // asymmetric motion partition, 2Nx( N/2) + 2Nx(3N/2)SIZE_2NxnD, // asymmetric motion partition, 2Nx(3N/2) + 2Nx( N/2)SIZE_nLx2N, // asymmetric motion partition, ( N/2)x2N + (3N/2)x2NSIZE_nRx2N, // asymmetric motion partition, (3N/2)x2N + ( N/2)x2NNUM_SIZES
};enum PredMode//预测类型
{MODE_NONE  = 0,MODE_INTER = (1 << 0),MODE_INTRA = (1 << 1),MODE_SKIP  = (1 << 2) | MODE_INTER
};// motion vector predictor direction used in AMVP
enum MVP_DIR
{MD_LEFT = 0,    // MVP of left blockMD_ABOVE,       // MVP of above blockMD_ABOVE_RIGHT, // MVP of above right blockMD_BELOW_LEFT,  // MVP of below left blockMD_ABOVE_LEFT,  // MVP of above left blockMD_COLLOCATED   // MVP of temporal neighbour
};struct CUGeom//CU的几何信息 在FrameEncoder类被引用
{enum {INTRA           = 1<<0, // 暂无用到 CU is intra predictedPRESENT         = 1<<1, // CU不是完全在图像外(只要有一部分在图像内就有此标志位)值 2 CU is not completely outside the frameSPLIT_MANDATORY = 1<<2, // CU节点为被推荐划分(一般是处于边界情况,当前CU一部分内容在图像外面)值为4 CU split is mandatory if CU is inside frame and can be splitLEAF            = 1<<3, // CU是叶子节点,即是8x8块(默认配置最小CU是8x8的情况下)值为 8 CU is a leaf node of the CTUSPLIT           = 1<<4, // 确定划分 SPLIT_MANDATORY 出现一定出现SPLIT  CU is currently split in four child CUs.};// (1 + 4 + 16 + 64) = 85.enum { MAX_GEOMS = 85 };//一个Geom的个数 (1 + 4 + 16 + 64) = 85.uint32_t log2CUSize;    // 当前的CUsize Log of the CU size.uint32_t childOffset;   // 表示从当前位置到第一个子cU的偏移量 offset of the first child CU from current CUuint32_t absPartIdx;    // 当前CU在LCU中4x4 zizag地址 Part index of this CU in terms of 4x4 blocks.uint32_t numPartitions; // 当前CU有多少4x4块 Number of 4x4 blocks in the CUuint32_t flags;         // 当前CU的块状态  CU flags.uint32_t depth;         // 当前CU的深度 depth of this CU relative from CTU
};
/*
样例-Y
以MaxCU 64 MinCU 8 width 640  heigh 240, 为例
申请空间: allocGeoms * CUGeom::MAX_GEOMS = allocGeoms * 85 = 4*85
64x64:1
32x32:4
16x16:16
8x 8:64      1+4+16+64 = 85
数据详情:CUGeom.txt
数据排列方式是先64x64、32x32、32x32、32x32、32x32、16x16……
0—84:
64x64、32x32、16x16 的flag 为2 :PRESENT  8x8为:10 :1010, PRESENT和LEAF
85-169: 表示宽度不能整除CTU 。例如当前 416 = 6*64+32
64x64:flag为22  10110, SPLIT、PRESENT、SPLIT_MANDATORY
32x32:左边两个为 2: PRESENT  ,右边两个为:0
16x16:最右边扩充的为0。其它为2
8x8:正常的为10 PRESENT和LEAF, 扩边的为8:LEAF
170-254: 表示高度不能整除CTU 。例如当前 240 = 3*64+48
64x64:flag为22  10110, SPLIT、PRESENT、SPLIT_MANDATORY
32x32:上边两个为 2: PRESENT  ,下边两个为:22  10110, SPLIT、PRESENT、SPLIT_MANDATORY  因为当前不足32x32
16x16:最下边扩充的为0。其它为2
8x8:正常的为10 PRESENT和LEAF, 扩边的为8:LEAF
255-339: 表示宽度不能整除CTU 且高度不能整除CTU
64x64:flag为22  10110, SPLIT、PRESENT、SPLIT_MANDATORY
32x32:左上角一个为 2: PRESENT  ,右边两个为0,左下角为:22  10110, SPLIT、PRESENT、SPLIT_MANDATORY  因为当前不足32x32
16x16:右边和下边扩充的为0。其它为2
8x8:正常的为10 PRESENT和LEAF, 扩边的为8:LEAF
**/struct MVField
{MV  mv;int refIdx;
};// Structure that keeps the neighbour's MV information.
struct InterNeighbourMV
{// Neighbour MV. The index represents the list.MV mv[2];// Collocated right bottom CU addr.uint32_t cuAddr[2];// For spatial prediction, this field contains the reference index// in each list (-1 if not available).//// For temporal prediction, the first value is used for the // prediction with list 0. The second value is used for the prediction // with list 1. For each value, the first four bits are the reference index // associated to the PMV, and the fifth bit is the list associated to the PMV.// if both reference indices are -1, then unifiedRef is also -1union { int16_t refIdx[2]; int32_t unifiedRef; };
};typedef void(*cucopy_t)(uint8_t* dst, uint8_t* src); // dst and src are aligned to MIN(size, 32)
typedef void(*cubcast_t)(uint8_t* dst, uint8_t val); // dst is aligned to MIN(size, 32)// Partition count table, index represents partitioning mode.
const uint32_t nbPartsTable[8] = { 1, 2, 2, 4, 2, 2, 2, 2 };// Partition table.
// First index is partitioning mode. Second index is partition index.
// Third index is 0 for partition sizes, 1 for partition offsets. The
// sizes and offsets are encoded as two packed 4-bit values (X,Y).
// X and Y represent 1/4 fractions of the block size.
const uint32_t partTable[8][4][2] =
{//        XY{ { 0x44, 0x00 }, { 0x00, 0x00 }, { 0x00, 0x00 }, { 0x00, 0x00 } }, // SIZE_2Nx2N.{ { 0x42, 0x00 }, { 0x42, 0x02 }, { 0x00, 0x00 }, { 0x00, 0x00 } }, // SIZE_2NxN.{ { 0x24, 0x00 }, { 0x24, 0x20 }, { 0x00, 0x00 }, { 0x00, 0x00 } }, // SIZE_Nx2N.{ { 0x22, 0x00 }, { 0x22, 0x20 }, { 0x22, 0x02 }, { 0x22, 0x22 } }, // SIZE_NxN.{ { 0x41, 0x00 }, { 0x43, 0x01 }, { 0x00, 0x00 }, { 0x00, 0x00 } }, // SIZE_2NxnU.{ { 0x43, 0x00 }, { 0x41, 0x03 }, { 0x00, 0x00 }, { 0x00, 0x00 } }, // SIZE_2NxnD.{ { 0x14, 0x00 }, { 0x34, 0x10 }, { 0x00, 0x00 }, { 0x00, 0x00 } }, // SIZE_nLx2N.{ { 0x34, 0x00 }, { 0x14, 0x30 }, { 0x00, 0x00 }, { 0x00, 0x00 } }  // SIZE_nRx2N.
};// Partition Address table.
// First index is partitioning mode. Second index is partition address.
const uint32_t partAddrTable[8][4] =
{{ 0x00, 0x00, 0x00, 0x00 }, // SIZE_2Nx2N.{ 0x00, 0x08, 0x08, 0x08 }, // SIZE_2NxN.{ 0x00, 0x04, 0x04, 0x04 }, // SIZE_Nx2N.{ 0x00, 0x04, 0x08, 0x0C }, // SIZE_NxN.{ 0x00, 0x02, 0x02, 0x02 }, // SIZE_2NxnU.{ 0x00, 0x0A, 0x0A, 0x0A }, // SIZE_2NxnD.{ 0x00, 0x01, 0x01, 0x01 }, // SIZE_nLx2N.{ 0x00, 0x05, 0x05, 0x05 }  // SIZE_nRx2N.
};// Holds part data for a CU of a given size, from an 8x8 CU to a CTU
class CUData
{
public:static cubcast_t s_partSet[NUM_FULL_DEPTH]; // 存储set函数指针根据CTU大小确定,如CTU 64 [0]存储一次性set 16x16(因为当前有16x16 个4x4块)大小的函数指针 [1]存储一次性set 8x8(因为当前有8x8 个4x4块)大小的函数指针 ....pointer to broadcast set functions per absolute depthstatic uint32_t  s_numPartInCUSize;         // 存储一个CTU中每行或者列有多少4x4块FrameData*    m_encData;          //当前帧编码数据 只是指针 指向 frame.m_encData;const Slice*  m_slice;            //当前帧的slice  只是指针 指向 m_encData->m_slicecucopy_t      m_partCopy;         // 当前CU的copy函数指针 pointer to function that copies m_numPartitions elementscubcast_t     m_partSet;          // 当前CU的set函数指针  pointer to function that sets m_numPartitions elementscucopy_t      m_subPartCopy;      // 当前CU子块的copy函数指针 pointer to function that copies m_numPartitions/4 elements, may be NULLcubcast_t     m_subPartSet;       // 当前CU子块的set函数指针  pointer to function that sets m_numPartitions/4 elements, may be NULLuint32_t      m_cuAddr;           // CTU在帧中的编号 address of CTU within the picture in raster orderuint32_t      m_absIdxInCTU;      // 当前CU左上角在CTU4x4块中的zigzag标号 address of CU within its CTU in Z scan orderuint32_t      m_cuPelX;           // 当前CU左上角像素点在图像中的横向偏移像素个数 CU position within the picture, in pixels (X)uint32_t      m_cuPelY;           // 当前CU左上角像素点在图像中的纵向偏移像素个数CU position within the picture, in pixels (Y)uint32_t      m_numPartitions;    // 当前CU的4x4块个数 maximum number of 4x4 partitions within this CUuint32_t      m_chromaFormat;     // 如:420格式,色度宽高是亮度的1/2 ,则此处为1,表示需要右移1位uint32_t      m_hChromaShift;     // 如:420格式,色度宽高是亮度的1/2 ,则此处为1,表示需要右移1位uint32_t      m_vChromaShift;     // 如:420格式,色度宽高是亮度的1/2 ,则此处为1,表示需要右移1位/* Per-part data, stored contiguously */ //以下所有空间在CUDataMemPool中(以下全部按照4x4块存储)int8_t*       m_qp;               // 存储QP信息 (编码之前 赋值为ratecontrolstart函数估计的qp值)??? array of QP valuesuint8_t*      m_log2CUSize;       // 存储当前CU的CUsize 2^size = 真实大小  如16x16: 当前为4 array of cu log2Size TODO: seems redundant to depthuint8_t*      m_lumaIntraDir;     // intra块的亮度预测方向 array of intra directions (luma)uint8_t*      m_tqBypass;         // 存储当前是否应用transquant bypass  对残差不进行变换、量化及环路滤波 (对应参数的无损压缩模式) array of CU lossless flagsint8_t*       m_refIdx[2];        // 存储在list中参考帧的序号 array of motion reference indices per listuint8_t*      m_cuDepth;          // 存储当前CU所处的划分深度 array of depthsuint8_t*      m_predMode;         // 当前CU的类型:MODE_NONE、MODE_INTER、MODE_INTRA、MODE_SKIP array of prediction modesuint8_t*      m_partSize;         // 当前CU的划分方式:SIZE_2Nx2N、SIZE_2NxN、SIZE_Nx2N、SIZE_NxN、SIZE_2NxnU、SIZE_2NxnD、SIZE_nLx2N、SIZE_nRx2Narray of partition sizesuint8_t*      m_mergeFlag;        // ?当前PU是否应用MERGE模式  array of merge flagsuint8_t*      m_interDir;         // 存储当前所用的list信息:0:intra、1:list0 2:list2 3:bi模式  array of inter directionsuint8_t*      m_mvpIdx[2];        // 每个PU左上角的4x4块中存储了MVP选择的标号 [0]:list 0 [1] : list1 array of motion vector predictor candidates or merge candidate indices [0]uint8_t*      m_tuDepth;          // 相对于当前CU下的TU深度 array of transform indicesuint8_t*      m_transformSkip[3]; // 标记当前是否应用transform skip array of transform skipping flags per planeuint8_t*      m_cbf[3];           // 标记当前PU是否拥有残差 array of coded block flags (CBF) per planeuint8_t*      m_chromaIntraDir;   // 存储intra色度块的预测方向 array of intra directions (chroma)enum { BytesPerPartition = 21 };  // 各个模式的种数  combined sizeof() of all per-part datacoeff_t*      m_trCoeff[3];       // transformed coefficient buffer per planeMV*           m_mv[2];            // 存储相应PU的MV array of motion vectors per listMV*           m_mvd[2];           // 存储相应PU的MVD(注:skip块此位置不存信息)array of coded motion vector deltas per listenum { TMVP_UNIT_MASK = 0xF0 };  // mask for mapping index to into a compressed (reference) MV fieldconst CUData* m_cuAboveLeft;      // 指向当前左上的CTU 没有为null pointer to above-left neighbor CTUconst CUData* m_cuAboveRight;     // 指向当前右上的CTU 没有为null pointer to above-right neighbor CTUconst CUData* m_cuAbove;          // 指向当前上边的CTU 没有为null pointer to above neighbor CTUconst CUData* m_cuLeft;           // 指向当前左边的CTU 没有为null pointer to left neighbor CTUCUData();//初始化/** 函数功能             :初始化函数指针,获取CTU数据相应存储位置 /*  调用范围             :只在FrameData::create和Analysis::create函数中被调用* \参数 dataPool         :CU存储空间 * \参数 depth            :CU划分深度(FrameData::create 传入 0 Analysis::create 传入相应深度) * \参数 csp              :图像格式* \参数 instance         :每个CU的标号 * \返回                  :null* */void     initialize(const CUDataMemPool& dataPool, uint32_t depth, int csp, int instance);/** 函数功能       : 计算CU的几何信息/*  调用范围       : 只在FrameEncoder::initializeGeoms()函数中被调用* \参数 ctuWidth   : 宽度的余数* \参数 ctuHeight  : 高度的余数* \参数 maxCUSize  : 最大CU* \参数 minCUSize  : 最小CU* \参数 cuDataArray: 存储位置*   返回值         : null**/static void calcCTUGeoms(uint32_t ctuWidth, uint32_t ctuHeight, uint32_t maxCUSize, uint32_t minCUSize, CUGeom cuDataArray[CUGeom::MAX_GEOMS]);/** 函数功能             :初始化CTU/*  调用范围             :只在processRowEncoder函数中被调用* \参数 frame            :当前编码帧* \参数 cuAddr           :CTU在帧中的编号* \参数 qp               :通过ratecontrolstart估计的QP值* \返回                  :null* */void     initCTU(const Frame& frame, uint32_t cuAddr, int qp);/** 函数功能       : 根据cuGeom初始化当前子块的信息* \参数 ctu        : 上层大块* \参数 cuGeom     : 当前子块对应的一些几何(深度,位置等信息)信息* \参数 qp         : 当前的qp信息*   返回值         : null**/void     initSubCU(const CUData& ctu, const CUGeom& cuGeom, int qp);void     initLosslessCU(const CUData& cu, const CUGeom& cuGeom);/** 函数功能       : 将子块决策最优结果copy到父块对应位置中* \参数 subCU      : 当前子块* \参数 childGeom  : 当前子块的几何信息* \参数 subPartIdx : 当前子块的标号*   返回值         : null**/void     copyPartFrom(const CUData& cu, const CUGeom& childGeom, uint32_t subPartIdx);/** 函数功能       : 当前子块全部在图像外,设置当前子块的depth和块大小值* \参数 childGeom  : 当前子块的几何信息* \参数 subPartIdx : 当前子块的标号*   返回值         : null**/void     setEmptyPart(const CUGeom& childGeom, uint32_t subPartIdx);/** 函数功能       : 将当前cu决策信息赋值到CTU对应位置中* \参数 depth      : 当前的划分深度*   返回值         : null**/void     copyToPic(uint32_t depth) const;/* RD-0 methods called only from encodeResidue */void     copyFromPic(const CUData& ctu, const CUGeom& cuGeom);void     updatePic(uint32_t depth) const;/** 函数功能       : 设置划分方式:SIZE_2Nx2N、SIZE_2NxN、SIZE_Nx2N、SIZE_NxN、SIZE_2NxnU、SIZE_2NxnD、SIZE_nLx2N、SIZE* \参数 size       : 划分方式:SIZE_2Nx2N、SIZE_2NxN、SIZE_Nx2N、SIZE_NxN、SIZE_2NxnU、SIZE_2NxnD、SIZE_nLx2N、SIZE*   返回值         : null**/void     setPartSizeSubParts(PartSize size)    { m_partSet(m_partSize, (uint8_t)size); }/** 函数功能       : 设置CU类型:MODE_NONE、MODE_INTER、MODE_INTRA、MODE_SKIP * \参数 mode       : CU类型:MODE_NONE、MODE_INTER、MODE_INTRA、MODE_SKIP *   返回值         : null**/void     setPredModeSubParts(PredMode mode)    { m_partSet(m_predMode, (uint8_t)mode); }void     clearCbf()                            { m_partSet(m_cbf[0], 0); m_partSet(m_cbf[1], 0); m_partSet(m_cbf[2], 0); }/* these functions all take depth as an absolute depth from CTU, it is used to calculate the number of parts to copy *//** 函数功能       : 设置CU的量化参数值/*  调用范围       : 只在compressCTU、setQPSubCUs、finishCU、checkDQP、checkDQPForSplitPred函数中被调用* \参数 qp         : 当前CU的量化参数值* \参数 absPartIdx : compressCTU中为0、setQPSubCUs:????、finishCU:???、checkDQP:???、checkDQPForSplitPred:?* \参数 depth      : 当前CU的划分深度*   返回值         : null**/void     setQPSubParts(int8_t qp, uint32_t absPartIdx, uint32_t depth)                    { s_partSet[depth]((uint8_t*)m_qp + absPartIdx, (uint8_t)qp); }/** 函数功能       : 设置相对于当前CU下的TU深度* \参数 tuDepth    : 相对于当前CU下的TU深度* \参数 absPartIdx : 当前PU在当前CU下的zigzag偏移地址* \参数 depth      : 当前PU相对于CTU的深度*   返回值         : null**/void     setTUDepthSubParts(uint8_t tuDepth, uint32_t absPartIdx, uint32_t depth)         { s_partSet[depth](m_tuDepth + absPartIdx, tuDepth); }/** 函数功能       : 设置CU下对应PU的intra预测方向/*  调用范围       : 只在checkIntraInInter、estIntraPredQT函数中被调用* \参数 dir        : 亮度的预测方向* \参数 absPartIdx : 当前PU在当前CU下的zigzag偏移地址* \参数 depth      : 当前PU的划分深度(2Nx2N模式为CU划分深度  NxN模式为CU划分深度加1)*   返回值         : null**/void     setLumaIntraDirSubParts(uint8_t dir, uint32_t absPartIdx, uint32_t depth)        { s_partSet[depth](m_lumaIntraDir + absPartIdx, dir); }void     setChromIntraDirSubParts(uint8_t dir, uint32_t absPartIdx, uint32_t depth)       { s_partSet[depth](m_chromaIntraDir + absPartIdx, dir); }void     setCbfSubParts(uint8_t cbf, TextType ttype, uint32_t absPartIdx, uint32_t depth) { s_partSet[depth](m_cbf[ttype] + absPartIdx, cbf); }void     setCbfPartRange(uint8_t cbf, TextType ttype, uint32_t absPartIdx, uint32_t coveredPartIdxes) { memset(m_cbf[ttype] + absPartIdx, cbf, coveredPartIdxes); }/** 函数功能       : 标记当前是否应用transform skip* \参数 tskip      : 是否应用transformskip* \参数 ttype      : 用于指示 亮度、色度* \参数 absPartIdx : 当前PU在当前CU下的zigzag偏移地址* \参数 depth      : 当前PU相对于CTU的深度*   返回值         : null**/void     setTransformSkipSubParts(uint8_t tskip, TextType ttype, uint32_t absPartIdx, uint32_t depth) { s_partSet[depth](m_transformSkip[ttype] + absPartIdx, tskip); }void     setTransformSkipPartRange(uint8_t tskip, TextType ttype, uint32_t absPartIdx, uint32_t coveredPartIdxes) { memset(m_transformSkip[ttype] + absPartIdx, tskip, coveredPartIdxes); }bool     setQPSubCUs(int8_t qp, uint32_t absPartIdx, uint32_t depth);void     setPUInterDir(uint8_t dir, uint32_t absPartIdx, uint32_t puIdx);void     setPUMv(int list, const MV& mv, int absPartIdx, int puIdx);void     setPURefIdx(int list, int8_t refIdx, int absPartIdx, int puIdx);uint8_t  getCbf(uint32_t absPartIdx, TextType ttype, uint32_t tuDepth) const { return (m_cbf[ttype][absPartIdx] >> tuDepth) & 0x1; }uint8_t  getQtRootCbf(uint32_t absPartIdx) const                             { return m_cbf[0][absPartIdx] || m_cbf[1][absPartIdx] || m_cbf[2][absPartIdx]; }int8_t   getRefQP(uint32_t currAbsIdxInCTU) const;uint32_t getInterMergeCandidates(uint32_t absPartIdx, uint32_t puIdx, MVField (*candMvField)[2], uint8_t* candDir) const;void     clipMv(MV& outMV) const;int      getPMV(InterNeighbourMV *neighbours, uint32_t reference_list, uint32_t refIdx, MV* amvpCand, MV* pmv) const;void     getNeighbourMV(uint32_t puIdx, uint32_t absPartIdx, InterNeighbourMV* neighbours) const;/** 函数功能           : 分别获取intraCU下最小TU,最大TU* \参数 tuDepthRange[2]: 分别存储最小TU,最大TU* \参数 absPartIdx     : 在Entropy::encodeCU为当前CU的左上角标号,其它位置为0*   返回值             : null    **/void     getIntraTUQtDepthRange(uint32_t tuDepthRange[2], uint32_t absPartIdx) const;void     getInterTUQtDepthRange(uint32_t tuDepthRange[2], uint32_t absPartIdx) const;uint32_t getBestRefIdx(uint32_t subPartIdx) const { return ((m_interDir[subPartIdx] & 1) << m_refIdx[0][subPartIdx]) | (((m_interDir[subPartIdx] >> 1) & 1) << (m_refIdx[1][subPartIdx] + 16)); }uint32_t getPUOffset(uint32_t puIdx, uint32_t absPartIdx) const { return (partAddrTable[(int)m_partSize[absPartIdx]][puIdx] << (g_unitSizeDepth - m_cuDepth[absPartIdx]) * 2) >> 4; }uint32_t getNumPartInter(uint32_t absPartIdx) const              { return nbPartsTable[(int)m_partSize[absPartIdx]]; }/** 函数功能           : 判断当前是否是intra块 * \参数 absPartIdx     : 在当前CU的4x4标号   **/bool     isIntra(uint32_t absPartIdx) const   { return m_predMode[absPartIdx] == MODE_INTRA; }/** 函数功能           : 判断当前是否是inter块 (skip+intra)* \参数 absPartIdx     : 在当前CU的4x4标号   **/bool     isInter(uint32_t absPartIdx) const   { return !!(m_predMode[absPartIdx] & MODE_INTER); }/** 函数功能           : 判断当前是否是skip块* \参数 absPartIdx     : 在当前CU的4x4标号   **/bool     isSkipped(uint32_t absPartIdx) const { return m_predMode[absPartIdx] == MODE_SKIP; }bool     isBipredRestriction() const          { return m_log2CUSize[0] == 3 && m_partSize[0] != SIZE_2Nx2N; }void     getPartIndexAndSize(uint32_t puIdx, uint32_t& absPartIdx, int& puWidth, int& puHeight) const;void     getMvField(const CUData* cu, uint32_t absPartIdx, int picList, MVField& mvField) const;void     getAllowedChromaDir(uint32_t absPartIdx, uint32_t* modeList) const;/** 函数功能             : 获取3个最有可能的帧内预测模式 并A(左边)与B(上边)方向相同(或者都不是intra块)则返回1 不同返回2/*  调用范围             : 只在codeIntraDirLumaAng和getIntraRemModeBits函数中被调用* \参数 absPartIdx       : PU在CU的zigzag标号* \参数 intraDirPred     : 存储3个最有可能的帧内预测模式*   返回值               : A(左边)与B(上边)方向相同(或者都不是intra块)则返回1 不同返回2**/int      getIntraDirLumaPredictor(uint32_t absPartIdx, uint32_t* intraDirPred) const;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;void     getTUEntropyCodingParameters(TUEntropyCodingParameters &result, uint32_t absPartIdx, uint32_t log2TrSize, bool bIsLuma) const;/** 函数功能             : 获取参考点的CTU或者CU位置,获取参考点在获取CTU或者CU内部的zigzag标号位置* \参数 lPartUnitIdx     : 用于存储参考像素点在返回CU/CTU 内部的zigzag标号 1.参考像素点不在当前CTU:返回参考像素点所在CTU的zigzag标号2.参考像素点在当前CTU不在当前CU:返回参考像素点在当前CTU的zigzag标号  3.参考像素点在当前CU:回参考像素点在当前CU的zigzag标号* \参数 curPartUnitIdx   : 当前PU左边行某一4x4块在CTU中的zigzag标号(PU内部的左边)*   返回值               : 1.参考像素点不在当前CTU:返回参考的所在的CTU 2.参考像素点在当前CTU不在当前CU:返回当前CTU  3.参考像素点在当前CU:返回当前CU**/const CUData* getPULeft(uint32_t& lPartUnitIdx, uint32_t curPartUnitIdx) const;/** 函数功能             : 获取参考点的CTU或者CU位置,获取参考点在获取CTU或者CU内部的zigzag标号位置* \参数 alPartUnitIdx    : 用于存储参考像素点在返回CU/CTU 内部的zigzag标号 1.参考像素点不在当前CTU:返回参考像素点所在CTU的zigzag标号2.参考像素点在当前CTU不在当前CU:返回参考像素点在当前CTU的zigzag标号  3.参考像素点在当前CU:回参考像素点在当前CU的zigzag标号* \参数 curPartUnitIdx   : 当前PU上边行某一4x4块在CTU中的zigzag标号*   返回值               : 1.参考像素点不在当前CTU:返回参考的所在的CTU 2.参考像素点在当前CTU不在当前CU:返回当前CTU  3.参考像素点在当前CU:返回当前CU    **/const CUData* getPUAbove(uint32_t& aPartUnitIdx, uint32_t curPartUnitIdx) const;/** 函数功能             : 获取参考点的CTU或者CU位置,获取参考点在获取CTU或者CU内部的zigzag标号位置* \参数 alPartUnitIdx    : 用于存储参考像素点在返回CU/CTU 内部的zigzag标号 1.参考像素点不在当前CTU:返回参考像素点所在CTU的zigzag标号2.参考像素点在当前CTU不在当前CU:返回参考像素点在当前CTU的zigzag标号  3.参考像素点在当前CU:回参考像素点在当前CU的zigzag标号* \参数 curPartUnitIdx   : 当前PU左上角像素点在CTU中的zigzag标号*   返回值               : 1.参考像素点不在当前CTU:返回参考的所在的CTU2.参考像素点在当前CTU不在当前CU:返回当前CTU  3.参考像素点在当前CU:返回当前CU  **/const CUData* getPUAboveLeft(uint32_t& alPartUnitIdx, uint32_t curPartUnitIdx) const;const CUData* getPUAboveRight(uint32_t& arPartUnitIdx, uint32_t curPartUnitIdx) const;const CUData* getPUBelowLeft(uint32_t& blPartUnitIdx, uint32_t curPartUnitIdx) const;const CUData* getQpMinCuLeft(uint32_t& lPartUnitIdx, uint32_t currAbsIdxInCTU) const;const CUData* getQpMinCuAbove(uint32_t& aPartUnitIdx, uint32_t currAbsIdxInCTU) const;/** 函数功能             : 获取参考点的CTU或者CU位置,获取参考点在获取CTU或者CU内部的zigzag标号位置* \参数 alPartUnitIdx    : 用于存储参考像素点在返回CU/CTU 内部的zigzag标号 1.参考像素点不在当前CTU:返回参考像素点所在CTU的zigzag标号2.参考像素点在当前CTU不在当前CU:返回参考像素点在当前CTU的zigzag标号  3.参考像素点在当前CU:回参考像素点在当前CU的zigzag标号* \参数 curPartUnitIdx   : 当前PU右上角像素点在CTU中的zigzag标号* \参数 partUnitOffset   : 当前4x4块距离PU右上点位置的偏移值*   返回值               : 1.参考像素点不在当前CTU:返回参考的所在的CTU 2.参考像素点在当前CTU不在当前CU:返回当前CTU  3.参考像素点在当前CU:返回当前CU**/const CUData* getPUAboveRightAdi(uint32_t& arPartUnitIdx, uint32_t curPartUnitIdx, uint32_t partUnitOffset) const;/** 函数功能             : 获取参考点的CTU或者CU位置,获取参考点在获取CTU或者CU内部的zigzag标号位置* \参数 blPartUnitIdx    : 用于存储参考像素点在返回CU/CTU 内部的zigzag标号 1.参考像素点不在当前CTU:返回参考像素点所在CTU的zigzag标号2.参考像素点在当前CTU不在当前CU:返回参考像素点在当前CTU的zigzag标号  3.参考像素点在当前CU:回参考像素点在当前CU的zigzag标号* \参数 curPartUnitIdx   : 当前PU右上角像素点在CTU中的zigzag标号* \参数 partUnitOffset   : 当前4x4块距离PU左下点位置的偏移值*   返回值               : 1.参考像素点不在当前CTU:返回参考的所在的CTU 2.参考像素点在当前CTU不在当前CU:返回当前CTU  3.参考像素点在当前CU:返回当前CU**/const CUData* getPUBelowLeftAdi(uint32_t& blPartUnitIdx, uint32_t curPartUnitIdx, uint32_t partUnitOffset) const;protected:template<typename T>void setAllPU(T *p, const T& val, int absPartIdx, int puIdx);int8_t getLastCodedQP(uint32_t absPartIdx) const;int  getLastValidPartIdx(int absPartIdx) const;bool hasEqualMotion(uint32_t absPartIdx, const CUData& candCU, uint32_t candAbsPartIdx) const;/* Check whether the current PU and a spatial neighboring PU are in same merge region */bool isDiffMER(int xN, int yN, int xP, int yP) const { return ((xN >> 2) != (xP >> 2)) || ((yN >> 2) != (yP >> 2)); }// add possible motion vector predictor candidatesbool getDirectPMV(MV& pmv, InterNeighbourMV *neighbours, uint32_t picList, uint32_t refIdx) const;bool getIndirectPMV(MV& outMV, InterNeighbourMV *neighbours, uint32_t reference_list, uint32_t refIdx) const;void getInterNeighbourMV(InterNeighbourMV *neighbour, uint32_t partUnitIdx, MVP_DIR dir) const;bool getColMVP(MV& outMV, int& outRefIdx, int picList, int cuAddr, int absPartIdx) const;bool getCollocatedMV(int cuAddr, int partUnitIdx, InterNeighbourMV *neighbour) const;MV scaleMvByPOCDist(const MV& inMV, int curPOC, int curRefPOC, int colPOC, int colRefPOC) const;void     deriveLeftRightTopIdx(uint32_t puIdx, uint32_t& partIdxLT, uint32_t& partIdxRT) const;uint32_t deriveCenterIdx(uint32_t puIdx) const;uint32_t deriveRightBottomIdx(uint32_t puIdx) const;uint32_t deriveLeftBottomIdx(uint32_t puIdx) const;
};// TU settings for entropy encoding
struct TUEntropyCodingParameters//??? 在transformNxN、rdoQuant、codeCoeffNxN中应用
{const uint16_t *scan;const uint16_t *scanCG;ScanType        scanType;uint32_t        log2TrSizeCG;//TU按照CG为单位计算的尺寸  TU尺寸减2uint32_t        firstSignificanceMapContext;
};
//用于CU的空间申请和释放
struct CUDataMemPool //存在于FrameData类和ModeDepth中
{uint8_t* charMemBlock;   //用存储模式等数据 (空间大小为:当前CU的4x4块个数*一帧CTU个数*21  或者 当前CU的4x4块个数*预测模式个数*21) coeff_t* trCoeffMemBlock;//存储系数数据 (空间大小为:一帧CTU个数*CTU像素个数  或者 预测模式个数*CTU像素个数)MV*      mvMemBlock;     //存储MV数据  (空间大小为:当前CU的4x4块个数*4*一帧CTU个数:4表示: MV[0]、MV[1]、MVD[0]、MVD[1])CUDataMemPool() { charMemBlock = NULL; trCoeffMemBlock = NULL; mvMemBlock = NULL; }//初始化/** 函数功能       : 申请空间内存/*  调用范围       : 只 FrameData::create和Analysis::create函数中被调用* \参数  depth     : CU划分深度(FrameData::create 传入 0 Analysis::create 传入相应深度)* \参数  csp       : 图像格式* \参数numInstances: 需要申请内存的CU个数(FrameData::create 传入 一帧中CU的个数 Analysis::create 传入 预测模式个数:14 PRED_MERGE,PRED_SKIP,PRED_INTRA, PRED_2Nx2N,PRED_BIDIR,PRED_Nx2N,PRED_2NxN.....)* \返回            : 是否申请内存成功 */bool create(uint32_t depth, uint32_t csp, uint32_t numInstances){uint32_t numPartition = NUM_4x4_PARTITIONS >> (depth * 2);//获取当前CU的4x4块个数uint32_t cuSize = g_maxCUSize >> depth;                   //获取当前CU的sizeuint32_t sizeL = cuSize * cuSize;                         //获取当前CU的像素个数uint32_t sizeC = sizeL >> (CHROMA_H_SHIFT(csp) + CHROMA_V_SHIFT(csp));//色度块的像素个数CHECKED_MALLOC(trCoeffMemBlock, coeff_t, (sizeL + sizeC * 2) * numInstances);//申请系数存储空间CHECKED_MALLOC(charMemBlock, uint8_t, numPartition * numInstances * CUData::BytesPerPartition);//申请模式存储空间CHECKED_MALLOC(mvMemBlock, MV, numPartition * 4 * numInstances);//申请MV存储空间return true;fail:return false;}/** 函数功能   : 释放空间内存/*  调用范围   : 只FrameData::destroy()和Analysis::destroy()函数中被调用* \返回        : null */void destroy(){X265_FREE(trCoeffMemBlock);X265_FREE(mvMemBlock);X265_FREE(charMemBlock);}
};
}#endif // ifndef X265_CUDATA_H

x265-1.8版本-common/cudata.h注释相关推荐

  1. x265-1.7版本-common/cudata.h注释

    注:问号以及未注释部分 会在x265-1.8版本内更新  /********************************************************************** ...

  2. x265-1.8版本-common/framedata.h注释

    注:问号以及未注释部分 会在x265-1.9版本内更新 /*********************************************************************** ...

  3. x265-1.8版本-common/wavefront.h注释

    注:问号以及未注释部分 会在x265-1.9版本内更新 /*********************************************************************** ...

  4. x265-1.8版本-common/contexts.h注释

    注:问号以及未注释部分 会在x265-1.9版本内更新 /*********************************************************************** ...

  5. x265-1.8版本-common/lowres.h注释

    注:问号以及未注释部分 会在x265-1.9版本内更新 /*********************************************************************** ...

  6. x265-1.7版本-common/lowres.h注释

    注:问号以及未注释部分 会在x265-1.8版本内更新  /********************************************************************** ...

  7. x265-1.8版本-encoder/frameencoder.h注释

    注:问号以及未注释部分 会在x265-1.9版本内更新 /*********************************************************************** ...

  8. x265-1.7版本-encoder/frameencoder.h注释

    注:问号以及未注释部分 会在x265-1.8版本内更新 /*********************************************************************** ...

  9. x265-1.8版本-common/wavefront.cpp注释

    注:问号以及未注释部分 会在x265-1.9版本内更新 /*********************************************************************** ...

最新文章

  1. 生产热更新技术_Reifenh?user引入新一代PET热成型板材生产线
  2. 马斯克:4年内,SpaceX的第一艘火星飞船将发射
  3. html文件上传协议,HTTP 上传文件的协议格式
  4. 科沃斯机器人双十一全渠道成交额超7亿 两大爆款单品携手破亿
  5. Android开发三 如何安装 Android SDK 和Eclipse 插件
  6. centos6+nagios3.3.1+nrpe2.12
  7. 你不知道的javascript_为什么前端要学JavaScript?JS都有哪些逆天的功能?
  8. android编程实现128条形码的生成和识别
  9. wps下一步快捷键_wps后退前进快捷键是什么?
  10. Matlab绘制柱状图(含显著性差异*)
  11. IR2104电机驱动
  12. win8桌面计算机图标不见,win8桌面图标消失,win8桌面图标设置方法
  13. C++第14周项目1 - 动物怎么叫
  14. UTF-8编码占几个字节?
  15. html代码在线运行_在线运行html代码
  16. 中国崛起让西方乱了阵脚
  17. origin常用函数
  18. HIVE最全面入门指南
  19. 开启加盟模式,喜茶能否借此越过山丘?
  20. .Android手机邮箱设置详细教程

热门文章

  1. 移动web开发--移动端常见布局+流式布局和flex布局+携程网首页案例
  2. 阿里云肖力:云即信任
  3. 计算机作业ppt怎么做,《苏腾计算机作业》PPT课件.ppt
  4. 天润融通牵手葵网新保险电销青睐云呼叫
  5. 彩票摇奖 java_用java 实现彩票摇奖,猜拳程序
  6. 服务器配置地址不正确,网络连接配置不正确IP地址是否正确网络存在问题..._网络编辑_帮考网...
  7. 都吃移动营销饭,四大门户有什么不同姿势?
  8. 畅捷通T+和道一云单据接口对接
  9. 2019.1.21【NOIP提高组】模拟B组 JZOJ 4210 我才不是萝莉控呢
  10. Jmeter之Non HTTP response code: java.net.ConnectExceptionexception的解决办法