#ifndef X265_FRAMEDATA_H
#define X265_FRAMEDATA_H
#include "common.h"
#include "slice.h"
#include "cudata.h"
namespace X265_NS {
class PicYuv;
class JobProvider;
#define INTER_MODES 4
#define INTRA_MODES 3
struct FrameStats
{
int mvBits;
int coeffBits;
int miscBits;
int intra8x8Cnt;
int inter8x8Cnt;
int skip8x8Cnt;
double percent8x8Intra;
double percent8x8Inter;
double percent8x8Skip;
double avgLumaDistortion;
double avgChromaDistortion;
double avgPsyEnergy;
double avgSsimEnergy;
double avgResEnergy;
double percentIntraNxN;
double percentSkipCu[NUM_CU_DEPTH];
double percentMergeCu[NUM_CU_DEPTH];
double percentIntraDistribution[NUM_CU_DEPTH][INTRA_MODES];
double percentInterDistribution[NUM_CU_DEPTH][3];
double ipCostRatio;
uint64_t cntIntraNxN;
uint64_t totalCu;
uint64_t totalCtu;
uint64_t lumaDistortion;
uint64_t chromaDistortion;
uint64_t psyEnergy;
int64_t ssimEnergy;
uint64_t resEnergy;
uint64_t cntSkipCu[NUM_CU_DEPTH];
uint64_t cntMergeCu[NUM_CU_DEPTH];
uint64_t cntInter[NUM_CU_DEPTH];
uint64_t cntIntra[NUM_CU_DEPTH];
uint64_t cuInterDistribution[NUM_CU_DEPTH][INTER_MODES];
uint64_t cuIntraDistribution[NUM_CU_DEPTH][INTRA_MODES];
uint64_t totalPu[NUM_CU_DEPTH + 1];
uint64_t cntSkipPu[NUM_CU_DEPTH];
uint64_t cntIntraPu[NUM_CU_DEPTH];
uint64_t cntAmp[NUM_CU_DEPTH];
uint64_t cnt4x4;
uint64_t cntInterPu[NUM_CU_DEPTH][INTER_MODES - 1];
uint64_t cntMergePu[NUM_CU_DEPTH][INTER_MODES - 1];
FrameStats()
{
memset(this, 0, sizeof(FrameStats));
}
};
class FrameData
{
public:
Slice* m_slice;
SAOParam* m_saoParam;
const x265_param* m_param;
FrameData* m_freeListNext;
PicYuv* m_reconPic;
bool m_bHasReferences;
int m_frameEncoderID;
JobProvider* m_jobProvider;
CUDataMemPool m_cuMemPool;
CUData* m_picCTU;
RPS* m_spsrps;
int m_spsrpsIdx;
struct RCStatCU
{
uint32_t totalBits;
uint32_t vbvCost;
uint32_t intraVbvCost;
uint64_t avgCost[4];
uint32_t count[4];
double baseQp;
};
struct RCStatRow
{
uint32_t numEncodedCUs;
uint32_t encodedBits;
uint32_t satdForVbv;
uint32_t intraSatdForVbv;
uint32_t rowSatd;
uint32_t rowIntraSatd;
double rowQp;
double rowQpScale;
double sumQpRc;
double sumQpAq;
};
RCStatCU* m_cuStat;
RCStatRow* m_rowStat;
FrameStats m_frameStats;
struct PeriodicIR
{
uint32_t pirStartCol;
uint32_t pirEndCol;
int framesSinceLastPir;
};
PeriodicIR m_pir;
double m_avgQpRc;
double m_avgQpAq;
double m_rateFactor;
int m_picCsp;
uint32_t* m_meIntegral[INTEGRAL_PLANE_NUM];
uint32_t* m_meBuffer[INTEGRAL_PLANE_NUM];
FrameData();
bool create(const x265_param& param, const SPS& sps, int csp);
void reinit(const SPS& sps);
void destroy();
inline CUData* getPicCTU(uint32_t ctuAddr) { return &m_picCTU[ctuAddr]; }
};
struct analysis_intra_data
{
uint8_t* depth;
uint8_t* modes;
char* partSizes;
uint8_t* chromaModes;
};
struct analysis_inter_data
{
int32_t* ref;
uint8_t* depth;
uint8_t* modes;
uint8_t* partSize;
uint8_t* mergeFlag;
uint8_t* interDir;
uint8_t* mvpIdx[2];
int8_t* refIdx[2];
MV* mv[2];
};
struct analysis2PassFrameData
{
uint8_t* depth;
MV* m_mv[2];
int* mvpIdx[2];
int32_t* ref[2];
uint8_t* modes;
sse_t* distortion;
sse_t* ctuDistortion;
double* scaledDistortion;
double averageDistortion;
double sdDistortion;
uint32_t highDistortionCtuCount;
uint32_t lowDistortionCtuCount;
double* offset;
double* threshold;
};
}
#endif