<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 20, 2018 at 2:23 PM, <span dir="ltr"><<a href="mailto:aasaipriya@multicorewareinc.com" target="_blank">aasaipriya@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Aasaipriya Chandran <<a href="mailto:aasaipriya@multicorewareinc.com">aasaipriya@multicorewareinc.<wbr>com</a>><br>
# Date 1532075633 -19800<br>
# Fri Jul 20 14:03:53 2018 +0530<br>
# Node ID 9694dfbe83ac404bce0c88ca19ed06<wbr>decd93c71d<br>
# Parent fb1530b0e1b4ebd179b8098015213b<wbr>aeeb37c8d2<br>
Expose WeightParam, analysis_inter_data, analysis_intra_data and analysisDistortionData structures in API<br>
<br>
diff -r fb1530b0e1b4 -r 9694dfbe83ac source/common/framedata.h<br>
--- a/source/common/framedata.h Fri Jul 20 14:20:22 2018 +0530<br>
+++ b/source/common/framedata.h Fri Jul 20 14:03:53 2018 +0530<br>
@@ -179,42 +179,5 @@<br>
inline CUData* getPicCTU(uint32_t ctuAddr) { return &m_picCTU[ctuAddr]; }<br>
};<br>
<br>
-/* Stores intra analysis data for a single frame. This struct needs better packing */<br>
-struct analysis_intra_data<br>
-{<br>
- uint8_t* depth;<br>
- uint8_t* modes;<br>
- char* partSizes;<br>
- uint8_t* chromaModes;<br>
-};<br>
-<br>
-/* Stores inter analysis data for a single frame */<br>
-struct analysis_inter_data<br>
-{<br>
- int32_t* ref;<br>
- uint8_t* depth;<br>
- uint8_t* modes;<br>
- uint8_t* partSize;<br>
- uint8_t* mergeFlag;<br>
- uint8_t* interDir;<br>
- uint8_t* mvpIdx[2];<br>
- int8_t* refIdx[2];<br>
- MV* mv[2];<br>
- int64_t* sadCost;<br>
-};<br>
-<br>
-struct analysisDistortionData<br>
-{<br>
- sse_t* distortion;<br>
- sse_t* ctuDistortion;<br>
- double* scaledDistortion;<br>
- double averageDistortion;<br>
- double sdDistortion;<br>
- uint32_t highDistortionCtuCount;<br>
- uint32_t lowDistortionCtuCount;<br>
- double* offset;<br>
- double* threshold;<br>
-};<br>
-<br>
}<br>
#endif // ifndef X265_FRAMEDATA_H<br>
diff -r fb1530b0e1b4 -r 9694dfbe83ac source/encoder/analysis.cpp<br>
--- a/source/encoder/analysis.cpp Fri Jul 20 14:20:22 2018 +0530<br>
+++ b/source/encoder/analysis.cpp Fri Jul 20 14:03:53 2018 +0530<br>
@@ -37,7 +37,7 @@<br>
using namespace X265_NS;<br>
<br>
/* An explanation of rate distortion levels (--rd-level)<br>
- * <br>
+ *<br>
* rd-level 0 generates no recon per CU (NO RDO or Quant)<br>
*<br>
* sa8d selection between merge / skip / inter / intra and split<br>
@@ -70,6 +70,12 @@<br>
* rd-level 5,6 does RDO for each inter mode<br>
*/<br>
<br>
+#define COPY_TO_MV(s1, s2, d1, d2)\<br>
+ {\<br>
+ d1 = s1; \<br>
+ d2 = s2; \<br>
+ }<br>
+<br>
Analysis::Analysis()<br>
{<br>
m_reuseInterDataCTU = NULL;<br>
@@ -190,7 +196,7 @@<br>
if (m_param-><wbr>analysisMultiPassRefine && m_param->rc.bStatRead && (m_slice->m_sliceType != I_SLICE))<br>
{<br>
int numPredDir = m_slice->isInterP() ? 1 : 2;<br>
- m_reuseInterDataCTU = (analysis_inter_data*)m_frame-<wbr>>m_analysisData.interData;<br>
+ m_reuseInterDataCTU = m_frame->m_analysisData.<wbr>interData;<br>
for (int dir = 0; dir < numPredDir; dir++)<br>
{<br>
m_reuseMv[dir] = &m_reuseInterDataCTU->mv[dir][<wbr>ctu.m_cuAddr * ctu.m_numPartitions];<br>
@@ -204,7 +210,7 @@<br>
if ((m_param->analysisSave || m_param->analysisLoad) && m_slice->m_sliceType != I_SLICE && m_param->analysisReuseLevel > 1 && m_param->analysisReuseLevel < 10)<br>
{<br>
int numPredDir = m_slice->isInterP() ? 1 : 2;<br>
- m_reuseInterDataCTU = (analysis_inter_data*)m_frame-<wbr>>m_analysisData.interData;<br>
+ m_reuseInterDataCTU = m_frame->m_analysisData.<wbr>interData;<br>
m_reuseRef = &m_reuseInterDataCTU->ref [ctu.m_cuAddr * X265_MAX_PRED_MODE_PER_CTU * numPredDir];<br>
m_reuseDepth = &m_reuseInterDataCTU->depth[<wbr>ctu.m_cuAddr * ctu.m_numPartitions];<br>
m_reuseModes = &m_reuseInterDataCTU->modes[<wbr>ctu.m_cuAddr * ctu.m_numPartitions];<br>
@@ -221,7 +227,7 @@<br>
<br>
if (m_slice->m_sliceType == I_SLICE)<br>
{<br>
- analysis_intra_data* intraDataCTU = (analysis_intra_data*)m_frame-<wbr>>m_analysisData.intraData;<br>
+ x265_analysis_intra_data* intraDataCTU = m_frame->m_analysisData.<wbr>intraData;<br>
if (m_param->analysisLoad && m_param->analysisReuseLevel > 1)<br>
{<br>
memcpy(ctu.m_cuDepth, &intraDataCTU->depth[ctu.m_<wbr>cuAddr * numPartition], sizeof(uint8_t) * numPartition);<br>
@@ -240,7 +246,7 @@<br>
<br>
if (bCopyAnalysis)<br>
{<br>
- analysis_inter_data* interDataCTU = (analysis_inter_data*)m_frame-<wbr>>m_analysisData.interData;<br>
+ x265_analysis_inter_data* interDataCTU = m_frame->m_analysisData.<wbr>interData;<br>
int posCTU = ctu.m_cuAddr * numPartition;<br>
memcpy(ctu.m_cuDepth, &interDataCTU->depth[posCTU], sizeof(uint8_t) * numPartition);<br>
memcpy(ctu.m_predMode, &interDataCTU->modes[posCTU], sizeof(uint8_t) * numPartition);<br>
@@ -250,7 +256,7 @@<br>
<br>
if ((m_slice->m_sliceType == P_SLICE || m_param->bIntraInBFrames) && !m_param->bMVType)<br>
{<br>
- analysis_intra_data* intraDataCTU = (analysis_intra_data*)m_frame-<wbr>>m_analysisData.intraData;<br>
+ x265_analysis_intra_data* intraDataCTU = m_frame->m_analysisData.<wbr>intraData;<br>
memcpy(ctu.m_lumaIntraDir, &intraDataCTU->modes[posCTU], sizeof(uint8_t) * numPartition);<br>
memcpy(ctu.m_chromaIntraDir, &intraDataCTU->chromaModes[<wbr>posCTU], sizeof(uint8_t) * numPartition);<br>
}<br>
@@ -276,14 +282,14 @@<br>
}<br>
else if ((m_param->analysisLoad && m_param->analysisReuseLevel == 10) || ((m_param->bMVType == AVC_INFO) && m_param->analysisReuseLevel >= 7 && ctu.m_numPartitions <= 16))<br>
{<br>
- analysis_inter_data* interDataCTU = (analysis_inter_data*)m_frame-<wbr>>m_analysisData.interData;<br>
+ x265_analysis_inter_data* interDataCTU = m_frame->m_analysisData.<wbr>interData;<br>
int posCTU = ctu.m_cuAddr * numPartition;<br>
memcpy(ctu.m_cuDepth, &interDataCTU->depth[posCTU], sizeof(uint8_t) * numPartition);<br>
memcpy(ctu.m_predMode, &interDataCTU->modes[posCTU], sizeof(uint8_t) * numPartition);<br>
memcpy(ctu.m_partSize, &interDataCTU->partSize[<wbr>posCTU], sizeof(uint8_t) * numPartition);<br>
if ((m_slice->m_sliceType == P_SLICE || m_param->bIntraInBFrames) && !(m_param->bMVType == AVC_INFO))<br>
{<br>
- analysis_intra_data* intraDataCTU = (analysis_intra_data*)m_frame-<wbr>>m_analysisData.intraData;<br>
+ x265_analysis_intra_data* intraDataCTU = m_frame->m_analysisData.<wbr>intraData;<br>
memcpy(ctu.m_lumaIntraDir, &intraDataCTU->modes[posCTU], sizeof(uint8_t) * numPartition);<br>
memcpy(ctu.m_chromaIntraDir, &intraDataCTU->chromaModes[<wbr>posCTU], sizeof(uint8_t) * numPartition);<br>
}<br>
@@ -2455,13 +2461,15 @@<br>
PredictionUnit pu(<a href="http://mode.cu" rel="noreferrer" target="_blank">mode.cu</a>, cuGeom, part);<br>
if ((m_param->analysisLoad && m_param->analysisReuseLevel == 10) || (m_param->bMVType == AVC_INFO && m_param->analysisReuseLevel >= 7))<br>
{<br>
- analysis_inter_data* interDataCTU = (analysis_inter_data*)m_frame-<wbr>>m_analysisData.interData;<br>
+ x265_analysis_inter_data* interDataCTU = m_frame->m_analysisData.<wbr>interData;<br>
int cuIdx = (mode.cu.m_cuAddr * parentCTU.m_numPartitions) + cuGeom.absPartIdx;<br>
mode.cu.m_mergeFlag[pu.<wbr>puAbsPartIdx] = interDataCTU->mergeFlag[cuIdx + part];<br>
mode.cu.setPUInterDir(<wbr>interDataCTU->interDir[cuIdx + part], pu.puAbsPartIdx, part);<br>
for (int list = 0; list < m_slice->isInterB() + 1; list++)<br>
{<br>
- mode.cu.setPUMv(list, interDataCTU->mv[list][cuIdx + part], pu.puAbsPartIdx, part);<br>
+ MV dst; x265_analysis_MV src = interDataCTU->mv[list][cuIdx + part];<br>
+ COPY_TO_MV(src.x, src.y, dst.x, dst.y);<br>
+ mode.cu.setPUMv(list, dst, pu.puAbsPartIdx, part);<br>
mode.cu.setPURefIdx(list, interDataCTU->refIdx[list][<wbr>cuIdx + part], pu.puAbsPartIdx, part);<br>
mode.cu.m_mvpIdx[list][pu.<wbr>puAbsPartIdx] = interDataCTU->mvpIdx[list][<wbr>cuIdx + part];<br>
}<br>
@@ -2483,7 +2491,10 @@<br>
if (m_param->interRefine != 1)<br>
mvp = mode.amvpCand[list][ref][mode.<wbr>cu.m_mvpIdx[list][pu.<wbr>puAbsPartIdx]];<br>
else<br>
- mvp = interDataCTU->mv[list][cuIdx + part];<br>
+ {<br>
+ x265_analysis_MV src = interDataCTU->mv[list][cuIdx + part];<br>
+ COPY_TO_MV(src.x, src.y, mvp.x, mvp.y);<br>
+ }<br>
if (m_param->mvRefine || m_param->interRefine == 1)<br>
{<br>
MV outmv;<br>
@@ -3021,8 +3032,9 @@<br>
for (int32_t i = 0; i < numPredDir; i++)<br>
{<br>
int* ref = &m_reuseRef[i * m_frame->m_analysisData.<wbr>numPartitions * m_frame->m_analysisData.<wbr>numCUsInFrame];<br>
+ x265_analysis_MV src = m_reuseMv[i][cuGeom.<wbr>absPartIdx]; MV dst = bestME[i].mv;<br>
bestME[i].ref = ref[cuGeom.absPartIdx];<br>
- bestME[i].mv = m_reuseMv[i][cuGeom.<wbr>absPartIdx];<br>
+ COPY_TO_MV(src.x, src.y, dst.x, dst.y);<br>
bestME[i].mvpIdx = m_reuseMvpIdx[i][cuGeom.<wbr>absPartIdx];<br>
}<br>
}<br>
@@ -3085,9 +3097,10 @@<br>
MotionData* bestME = interMode.bestME[part];<br>
for (int32_t i = 0; i < numPredDir; i++)<br>
{<br>
+ x265_analysis_MV src = m_reuseMv[i][cuGeom.<wbr>absPartIdx]; MV dst = bestME[i].mv;<br>
int* ref = &m_reuseRef[i * m_frame->m_analysisData.<wbr>numPartitions * m_frame->m_analysisData.<wbr>numCUsInFrame];<br>
bestME[i].ref = ref[cuGeom.absPartIdx];<br>
- bestME[i].mv = m_reuseMv[i][cuGeom.<wbr>absPartIdx];<br>
+ COPY_TO_MV(src.x, src.y, dst.x, dst.y);<br>
bestME[i].mvpIdx = m_reuseMvpIdx[i][cuGeom.<wbr>absPartIdx];<br>
}<br>
}<br>
@@ -3562,7 +3575,7 @@<br>
<br>
if (m_param-><wbr>analysisMultiPassDistortion && m_param->rc.bStatRead)<br>
{<br>
- analysisDistortionData* distortionData = (analysisDistortionData*)m_<wbr>frame->m_analysisData.<wbr>distortionData;<br>
+ x265_analysis_distortion_data* distortionData = m_frame->m_analysisData.<wbr>distortionData;<br>
if ((distortionData->threshold[<wbr>ctu.m_cuAddr] < 0.9 || distortionData->threshold[ctu.<wbr>m_cuAddr] > 1.1)<br>
&& distortionData-><wbr>highDistortionCtuCount && distortionData-><wbr>lowDistortionCtuCount)<br>
qp += distortionData->offset[ctu.m_<wbr>cuAddr];<br>
diff -r fb1530b0e1b4 -r 9694dfbe83ac source/encoder/analysis.h<br>
--- a/source/encoder/analysis.h Fri Jul 20 14:20:22 2018 +0530<br>
+++ b/source/encoder/analysis.h Fri Jul 20 14:03:53 2018 +0530<br>
@@ -123,13 +123,13 @@<br>
<br>
protected:<br>
/* Analysis data for save/load mode, writes/reads data based on absPartIdx */<br>
- analysis_inter_data* m_reuseInterDataCTU;<br>
- int32_t* m_reuseRef;<br>
- uint8_t* m_reuseDepth;<br>
- uint8_t* m_reuseModes;<br>
- uint8_t* m_reusePartSize;<br>
- uint8_t* m_reuseMergeFlag;<br>
- MV* m_reuseMv[2];<br>
+ x265_analysis_inter_data* m_reuseInterDataCTU;<br>
+ int32_t* m_reuseRef;<br>
+ uint8_t* m_reuseDepth;<br>
+ uint8_t* m_reuseModes;<br>
+ uint8_t* m_reusePartSize;<br>
+ uint8_t* m_reuseMergeFlag;<br>
+ x265_analysis_MV* m_reuseMv[2];<br>
uint8_t* m_reuseMvpIdx[2];<br>
<br>
uint32_t m_splitRefIdx[4];<br>
diff -r fb1530b0e1b4 -r 9694dfbe83ac source/encoder/api.cpp<br>
--- a/source/encoder/api.cpp Fri Jul 20 14:20:22 2018 +0530<br>
+++ b/source/encoder/api.cpp Fri Jul 20 14:03:53 2018 +0530<br>
@@ -406,14 +406,16 @@<br>
void x265_alloc_analysis_data(x265_<wbr>param *param, x265_analysis_data* analysis)<br>
{<br>
X265_CHECK(analysis-><wbr>sliceType, "invalid slice type\n");<br>
- analysis->interData = analysis->intraData = analysis->distortionData = NULL;<br>
+ analysis->interData = NULL;<br>
+ analysis->intraData = NULL;<br>
+ analysis->distortionData = NULL;<br>
bool isVbv = param->rc.vbvMaxBitrate > 0 && param->rc.vbvBufferSize > 0;<br>
int numDir = 2; //irrespective of P or B slices set direction as 2<br>
uint32_t numPlanes = param->internalCsp == X265_CSP_I400 ? 1 : 3;<br>
<br>
//Allocate memory for distortionData pointer<br>
- analysisDistortionData *distortionData = (analysisDistortionData*)<wbr>analysis->distortionData;<br>
- CHECKED_MALLOC_ZERO(<wbr>distortionData, analysisDistortionData, 1);<br>
+ x265_analysis_distortion_data *distortionData = analysis->distortionData;<br>
+ CHECKED_MALLOC_ZERO(<wbr>distortionData, x265_analysis_distortion_data, 1);<br>
CHECKED_MALLOC_ZERO(<wbr>distortionData->distortion, sse_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
if (param->rc.bStatRead)<br>
{<br>
@@ -434,14 +436,14 @@<br>
<br>
//Allocate memory for weightParam pointer<br>
if (!(param->bMVType == AVC_INFO))<br>
- CHECKED_MALLOC_ZERO(analysis-><wbr>wt, WeightParam, numPlanes * numDir);<br>
+ CHECKED_MALLOC_ZERO(analysis-><wbr>wt, x265_weight_param, numPlanes * numDir);<br>
<br>
if (param->analysisReuseLevel < 2)<br>
return;<br>
<br>
//Allocate memory for intraData pointer<br>
- analysis_intra_data *intraData = (analysis_intra_data*)<wbr>analysis->intraData;<br>
- CHECKED_MALLOC_ZERO(intraData, analysis_intra_data, 1);<br>
+ x265_analysis_intra_data *intraData = analysis->intraData;<br>
+ CHECKED_MALLOC_ZERO(intraData, x265_analysis_intra_data, 1);<br>
CHECKED_MALLOC(intraData-><wbr>depth, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
CHECKED_MALLOC(intraData-><wbr>modes, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
CHECKED_MALLOC(intraData-><wbr>partSizes, char, analysis->numPartitions * analysis->numCUsInFrame);<br>
@@ -449,15 +451,15 @@<br>
analysis->intraData = intraData;<br>
<br>
//Allocate memory for interData pointer based on ReuseLevels<br>
- analysis_inter_data *interData = (analysis_inter_data*)<wbr>analysis->interData;<br>
- CHECKED_MALLOC_ZERO(interData, analysis_inter_data, 1);<br>
+ x265_analysis_inter_data *interData = analysis->interData;<br>
+ CHECKED_MALLOC_ZERO(interData, x265_analysis_inter_data, 1);<br>
CHECKED_MALLOC(interData-><wbr>depth, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
CHECKED_MALLOC(interData-><wbr>modes, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
<br>
CHECKED_MALLOC_ZERO(interData-<wbr>>mvpIdx[0], uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
CHECKED_MALLOC_ZERO(interData-<wbr>>mvpIdx[1], uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
- CHECKED_MALLOC_ZERO(interData-<wbr>>mv[0], MV, analysis->numPartitions * analysis->numCUsInFrame);<br>
- CHECKED_MALLOC_ZERO(interData-<wbr>>mv[1], MV, analysis->numPartitions * analysis->numCUsInFrame);<br>
+ CHECKED_MALLOC_ZERO(interData-<wbr>>mv[0], x265_analysis_MV, analysis->numPartitions * analysis->numCUsInFrame);<br>
+ CHECKED_MALLOC_ZERO(interData-<wbr>>mv[1], x265_analysis_MV, analysis->numPartitions * analysis->numCUsInFrame);<br>
<br>
if (param->analysisReuseLevel > 4)<br>
{<br>
@@ -506,13 +508,13 @@<br>
//Free memory for distortionData pointers<br>
if (analysis->distortionData)<br>
{<br>
- X265_FREE(((<wbr>analysisDistortionData*)<wbr>analysis->distortionData)-><wbr>distortion);<br>
+ X265_FREE((analysis-><wbr>distortionData)->distortion);<br>
if (param->rc.bStatRead)<br>
{<br>
- X265_FREE(((<wbr>analysisDistortionData*)<wbr>analysis->distortionData)-><wbr>ctuDistortion);<br>
- X265_FREE(((<wbr>analysisDistortionData*)<wbr>analysis->distortionData)-><wbr>scaledDistortion);<br>
- X265_FREE(((<wbr>analysisDistortionData*)<wbr>analysis->distortionData)-><wbr>offset);<br>
- X265_FREE(((<wbr>analysisDistortionData*)<wbr>analysis->distortionData)-><wbr>threshold);<br>
+ X265_FREE((analysis-><wbr>distortionData)-><wbr>ctuDistortion);<br>
+ X265_FREE((analysis-><wbr>distortionData)-><wbr>scaledDistortion);<br>
+ X265_FREE((analysis-><wbr>distortionData)->offset);<br>
+ X265_FREE((analysis-><wbr>distortionData)->threshold);<br>
}<br>
X265_FREE(analysis-><wbr>distortionData);<br>
}<br>
@@ -527,10 +529,10 @@<br>
//Free memory for intraData pointers<br>
if (analysis->intraData)<br>
{<br>
- X265_FREE(((analysis_intra_<wbr>data*)analysis->intraData)-><wbr>depth);<br>
- X265_FREE(((analysis_intra_<wbr>data*)analysis->intraData)-><wbr>modes);<br>
- X265_FREE(((analysis_intra_<wbr>data*)analysis->intraData)-><wbr>partSizes);<br>
- X265_FREE(((analysis_intra_<wbr>data*)analysis->intraData)-><wbr>chromaModes);<br>
+ X265_FREE((analysis-><wbr>intraData)->depth);<br>
+ X265_FREE((analysis-><wbr>intraData)->modes);<br>
+ X265_FREE((analysis-><wbr>intraData)->partSizes);<br>
+ X265_FREE((analysis-><wbr>intraData)->chromaModes);<br>
X265_FREE(analysis->intraData)<wbr>;<br>
analysis->intraData = NULL;<br>
}<br>
@@ -538,26 +540,26 @@<br>
//Free interData pointers<br>
if (analysis->interData)<br>
{<br>
- X265_FREE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>depth);<br>
- X265_FREE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>modes);<br>
- X265_FREE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>mvpIdx[0]);<br>
- X265_FREE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>mvpIdx[1]);<br>
- X265_FREE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>mv[0]);<br>
- X265_FREE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>mv[1]);<br>
+ X265_FREE((analysis-><wbr>interData)->depth);<br>
+ X265_FREE((analysis-><wbr>interData)->modes);<br>
+ X265_FREE((analysis-><wbr>interData)->mvpIdx[0]);<br>
+ X265_FREE((analysis-><wbr>interData)->mvpIdx[1]);<br>
+ X265_FREE((analysis-><wbr>interData)->mv[0]);<br>
+ X265_FREE((analysis-><wbr>interData)->mv[1]);<br>
<br>
if (param->analysisReuseLevel > 4)<br>
{<br>
- X265_FREE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>mergeFlag);<br>
- X265_FREE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>partSize);<br>
+ X265_FREE((analysis-><wbr>interData)->mergeFlag);<br>
+ X265_FREE((analysis-><wbr>interData)->partSize);<br>
}<br>
if (param->analysisReuseLevel >= 7)<br>
{<br>
int numDir = 2;<br>
- X265_FREE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>interDir);<br>
- X265_FREE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>sadCost);<br>
+ X265_FREE((analysis-><wbr>interData)->interDir);<br>
+ X265_FREE((analysis-><wbr>interData)->sadCost);<br>
for (int dir = 0; dir < numDir; dir++)<br>
{<br>
- X265_FREE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>refIdx[dir]);<br>
+ X265_FREE((analysis-><wbr>interData)->refIdx[dir]);<br>
if (analysis->modeFlag[dir] != NULL)<br>
{<br>
X265_FREE(analysis->modeFlag[<wbr>dir]);<br>
@@ -566,7 +568,7 @@<br>
}<br>
}<br>
else<br>
- X265_FREE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>ref);<br>
+ X265_FREE((analysis-><wbr>interData)->ref);<br>
X265_FREE(analysis->interData)<wbr>;<br>
analysis->interData = NULL;<br>
}<br>
diff -r fb1530b0e1b4 -r 9694dfbe83ac source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Fri Jul 20 14:20:22 2018 +0530<br>
+++ b/source/encoder/encoder.cpp Fri Jul 20 14:03:53 2018 +0530<br>
@@ -546,8 +546,8 @@<br>
curFrame->m_analysisData.<wbr>numPartitions = m_param->num4x4Partitions;<br>
int num16x16inCUWidth = m_param->maxCUSize >> 4;<br>
uint32_t ctuAddr, offset, cuPos;<br>
- analysis_intra_data * intraData = (analysis_intra_data *)curFrame->m_analysisData.<wbr>intraData;<br>
- analysis_intra_data * srcIntraData = (analysis_intra_data *)analysis_data->intraData;<br>
+ x265_analysis_intra_data * intraData = curFrame->m_analysisData.<wbr>intraData;<br>
+ x265_analysis_intra_data * srcIntraData = analysis_data->intraData;<br>
for (int i = 0; i < mbImageHeight; i++)<br>
{<br>
for (int j = 0; j < mbImageWidth; j++)<br>
@@ -576,8 +576,8 @@<br>
curFrame->m_analysisData.<wbr>numPartitions = m_param->num4x4Partitions;<br>
int num16x16inCUWidth = m_param->maxCUSize >> 4;<br>
uint32_t ctuAddr, offset, cuPos;<br>
- analysis_inter_data * interData = (analysis_inter_data *)curFrame->m_analysisData.<wbr>interData;<br>
- analysis_inter_data * srcInterData = (analysis_inter_data*)<wbr>analysis_data->interData;<br>
+ x265_analysis_inter_data * interData = curFrame->m_analysisData.<wbr>interData;<br>
+ x265_analysis_inter_data * srcInterData = analysis_data->interData;<br>
for (int i = 0; i < mbImageHeight; i++)<br>
{<br>
for (int j = 0; j < mbImageWidth; j++)<br>
@@ -652,8 +652,8 @@<br>
<br>
curFrame->m_analysisData.<wbr>numPartitions = m_param->num4x4Partitions;<br>
size_t count = 0;<br>
- analysis_intra_data * currIntraData = (analysis_intra_data *)curFrame->m_analysisData.<wbr>intraData;<br>
- analysis_intra_data * intraData = (analysis_intra_data *)analysis_data->intraData;<br>
+ x265_analysis_intra_data * currIntraData = curFrame->m_analysisData.<wbr>intraData;<br>
+ x265_analysis_intra_data * intraData = analysis_data->intraData;<br>
for (uint32_t d = 0; d < cuBytes; d++)<br>
{<br>
int bytes = curFrame->m_analysisData.<wbr>numPartitions >> ((intraData)->depth[d] * 2);<br>
@@ -673,14 +673,14 @@<br>
<br>
curFrame->m_analysisData.<wbr>numPartitions = m_param->num4x4Partitions;<br>
size_t count = 0;<br>
- analysis_inter_data * currInterData = (analysis_inter_data *)curFrame->m_analysisData.<wbr>interData;<br>
- analysis_inter_data * interData = (analysis_inter_data *)analysis_data->interData;<br>
+ x265_analysis_inter_data * currInterData = curFrame->m_analysisData.<wbr>interData;<br>
+ x265_analysis_inter_data * interData = analysis_data->interData;<br>
for (uint32_t d = 0; d < cuBytes; d++)<br>
{<br>
int bytes = curFrame->m_analysisData.<wbr>numPartitions >> ((interData)->depth[d] * 2);<br>
memset(&(currInterData)-><wbr>depth[count], (interData)->depth[d], bytes);<br>
memset(&(currInterData)-><wbr>modes[count], (interData)->modes[d], bytes);<br>
- memcpy(&(currInterData)-><wbr>sadCost[count], &((analysis_inter_data*)<wbr>analysis_data->interData)-><wbr>sadCost[d], bytes);<br>
+ memcpy(&(currInterData)-><wbr>sadCost[count], &(analysis_data->interData)-><wbr>sadCost[d], bytes);<br>
if (m_param->analysisReuseLevel > 4)<br>
{<br>
memset(&(currInterData)-><wbr>partSize[count], (interData)->partSize[d], bytes);<br>
@@ -3203,8 +3203,8 @@<br>
if (m_param->bUseAnalysisFile)<br>
fseeko(m_analysisFileIn, totalConsumedBytes + paramBytes, SEEK_SET);<br>
const x265_analysis_data *picData = &(picIn->analysisData);<br>
- analysis_intra_data *intraPic = (analysis_intra_data *)picData->intraData;<br>
- analysis_inter_data *interPic = (analysis_inter_data *)picData->interData;<br>
+ x265_analysis_intra_data *intraPic = picData->intraData;<br>
+ x265_analysis_inter_data *interPic = picData->interData;<br>
<br>
int poc; uint32_t frameRecordSize;<br>
X265_FREAD(&frameRecordSize, sizeof(uint32_t), 1, m_analysisFileIn, &(picData->frameRecordSize));<br>
@@ -3305,22 +3305,22 @@<br>
if (partSizes[d] == SIZE_NxN)<br>
partSizes[d] = SIZE_2Nx2N;<br>
}<br>
- memset(&((analysis_intra_data *)analysis->intraData)->depth[<wbr>count], depthBuf[d], bytes);<br>
- memset(&((analysis_intra_data *)analysis->intraData)-><wbr>chromaModes[count], modeBuf[d], bytes);<br>
- memset(&((analysis_intra_data *)analysis->intraData)-><wbr>partSizes[count], partSizes[d], bytes);<br>
+ memset(&(analysis->intraData)-<wbr>>depth[count], depthBuf[d], bytes);<br>
+ memset(&(analysis->intraData)-<wbr>>chromaModes[count], modeBuf[d], bytes);<br>
+ memset(&(analysis->intraData)-<wbr>>partSizes[count], partSizes[d], bytes);<br>
count += bytes;<br>
}<br>
<br>
if (!m_param->scaleFactor)<br>
{<br>
- X265_FREAD(((analysis_intra_<wbr>data *)analysis->intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFileIn, intraPic->modes);<br>
+ X265_FREAD((analysis-><wbr>intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFileIn, intraPic->modes);<br>
}<br>
else<br>
{<br>
uint8_t *tempLumaBuf = X265_MALLOC(uint8_t, analysis->numCUsInFrame * scaledNumPartition);<br>
X265_FREAD(tempLumaBuf, sizeof(uint8_t), analysis->numCUsInFrame * scaledNumPartition, m_analysisFileIn, intraPic->modes);<br>
for (uint32_t ctu32Idx = 0, cnt = 0; ctu32Idx < analysis->numCUsInFrame * scaledNumPartition; ctu32Idx++, cnt += factor)<br>
- memset(&((analysis_intra_data *)analysis->intraData)->modes[<wbr>cnt], tempLumaBuf[ctu32Idx], factor);<br>
+ memset(&(analysis->intraData)-<wbr>>modes[cnt], tempLumaBuf[ctu32Idx], factor);<br>
X265_FREE(tempLumaBuf);<br>
}<br>
X265_FREE(tempBuf);<br>
@@ -3390,36 +3390,36 @@<br>
int bytes = analysis->numPartitions >> (depthBuf[d] * 2);<br>
if (m_param->scaleFactor && modeBuf[d] == MODE_INTRA && depthBuf[d] == 0)<br>
depthBuf[d] = 1;<br>
- memset(&((analysis_inter_data *)analysis->interData)->depth[<wbr>count], depthBuf[d], bytes);<br>
- memset(&((analysis_inter_data *)analysis->interData)->modes[<wbr>count], modeBuf[d], bytes);<br>
+ memset(&(analysis->interData)-<wbr>>depth[count], depthBuf[d], bytes);<br>
+ memset(&(analysis->interData)-<wbr>>modes[count], modeBuf[d], bytes);<br>
if (m_param->analysisReuseLevel > 4)<br>
{<br>
if (m_param->scaleFactor && modeBuf[d] == MODE_INTRA && partSize[d] == SIZE_NxN)<br>
partSize[d] = SIZE_2Nx2N;<br>
- memset(&((analysis_inter_data *)analysis->interData)-><wbr>partSize[count], partSize[d], bytes);<br>
+ memset(&(analysis->interData)-<wbr>>partSize[count], partSize[d], bytes);<br>
int numPU = (modeBuf[d] == MODE_INTRA) ? 1 : nbPartsTable[(int)partSize[d]]<wbr>;<br>
for (int pu = 0; pu < numPU; pu++)<br>
{<br>
if (pu) d++;<br>
- ((analysis_inter_data *)analysis->interData)-><wbr>mergeFlag[count + pu] = mergeFlag[d];<br>
+ (analysis->interData)-><wbr>mergeFlag[count + pu] = mergeFlag[d];<br>
if (m_param->analysisReuseLevel == 10)<br>
{<br>
- ((analysis_inter_data *)analysis->interData)-><wbr>interDir[count + pu] = interDir[d];<br>
+ (analysis->interData)-><wbr>interDir[count + pu] = interDir[d];<br>
for (uint32_t i = 0; i < numDir; i++)<br>
{<br>
- ((analysis_inter_data *)analysis->interData)-><wbr>mvpIdx[i][count + pu] = mvpIdx[i][d];<br>
- ((analysis_inter_data *)analysis->interData)-><wbr>refIdx[i][count + pu] = refIdx[i][d];<br>
+ (analysis->interData)->mvpIdx[<wbr>i][count + pu] = mvpIdx[i][d];<br>
+ (analysis->interData)->refIdx[<wbr>i][count + pu] = refIdx[i][d];<br>
if (m_param->scaleFactor)<br>
{<br>
mv[i][d].x *= (int16_t)m_param->scaleFactor;<br>
mv[i][d].y *= (int16_t)m_param->scaleFactor;<br>
}<br>
- memcpy(&((analysis_inter_data *)analysis->interData)->mv[i][<wbr>count + pu], &mv[i][d], sizeof(MV));<br>
+ memcpy(&(analysis->interData)-<wbr>>mv[i][count + pu], &mv[i][d], sizeof(MV));<br>
}<br>
}<br>
}<br>
if (m_param->analysisReuseLevel == 10 && bIntraInInter)<br>
- memset(&((analysis_intra_data *)analysis->intraData)-><wbr>chromaModes[count], chromaDir[d], bytes);<br>
+ memset(&(analysis->intraData)-<wbr>>chromaModes[count], chromaDir[d], bytes);<br>
}<br>
count += bytes;<br>
}<br>
@@ -3438,20 +3438,20 @@<br>
{<br>
if (!m_param->scaleFactor)<br>
{<br>
- X265_FREAD(((analysis_intra_<wbr>data *)analysis->intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFileIn, intraPic->modes);<br>
+ X265_FREAD((analysis-><wbr>intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFileIn, intraPic->modes);<br>
}<br>
else<br>
{<br>
uint8_t *tempLumaBuf = X265_MALLOC(uint8_t, analysis->numCUsInFrame * scaledNumPartition);<br>
X265_FREAD(tempLumaBuf, sizeof(uint8_t), analysis->numCUsInFrame * scaledNumPartition, m_analysisFileIn, intraPic->modes);<br>
for (uint32_t ctu32Idx = 0, cnt = 0; ctu32Idx < analysis->numCUsInFrame * scaledNumPartition; ctu32Idx++, cnt += factor)<br>
- memset(&((analysis_intra_data *)analysis->intraData)->modes[<wbr>cnt], tempLumaBuf[ctu32Idx], factor);<br>
+ memset(&(analysis->intraData)-<wbr>>modes[cnt], tempLumaBuf[ctu32Idx], factor);<br>
X265_FREE(tempLumaBuf);<br>
}<br>
}<br>
}<br>
else<br>
- X265_FREAD(((analysis_inter_<wbr>data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFileIn, interPic->ref);<br>
+ X265_FREAD((analysis-><wbr>interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFileIn, interPic->ref);<br>
<br>
consumedBytes += frameRecordSize;<br>
if (numDir == 1)<br>
@@ -3482,8 +3482,8 @@<br>
fseeko(m_analysisFileIn, totalConsumedBytes + paramBytes, SEEK_SET);<br>
<br>
const x265_analysis_data *picData = &(picIn->analysisData);<br>
- analysis_intra_data *intraPic = (analysis_intra_data *)picData->intraData;<br>
- analysis_inter_data *interPic = (analysis_inter_data *)picData->interData;<br>
+ x265_analysis_intra_data *intraPic = picData->intraData;<br>
+ x265_analysis_inter_data *interPic = picData->interData;<br>
<br>
int poc; uint32_t frameRecordSize;<br>
X265_FREAD(&frameRecordSize, sizeof(uint32_t), 1, m_analysisFileIn, &(picData->frameRecordSize));<br>
@@ -3629,9 +3629,9 @@<br>
<br>
for (int numCTU = 0; numCTU < numCTUCopied; numCTU++)<br>
{<br>
- memset(&((analysis_intra_data *)analysis->intraData)->depth[<wbr>count], depthBuf[d], bytes);<br>
- memset(&((analysis_intra_data *)analysis->intraData)-><wbr>chromaModes[count], modeBuf[d], bytes);<br>
- memset(&((analysis_intra_data *)analysis->intraData)-><wbr>partSizes[count], partSizes[d], bytes);<br>
+ memset(&(analysis->intraData)-<wbr>>depth[count], depthBuf[d], bytes);<br>
+ memset(&(analysis->intraData)-<wbr>>chromaModes[count], modeBuf[d], bytes);<br>
+ memset(&(analysis->intraData)-<wbr>>partSizes[count], partSizes[d], bytes);<br>
count += bytes;<br>
d += getCUIndex(&cuLoc, &count, bytes, 1);<br>
}<br>
@@ -3645,7 +3645,7 @@<br>
uint32_t cnt = 0;<br>
for (uint32_t ctu32Idx = 0; ctu32Idx < analysis->numCUsInFrame * scaledNumPartition; ctu32Idx++)<br>
{<br>
- memset(&((analysis_intra_data *)analysis->intraData)->modes[<wbr>cnt], tempLumaBuf[ctu32Idx], factor);<br>
+ memset(&(analysis->intraData)-<wbr>>modes[cnt], tempLumaBuf[ctu32Idx], factor);<br>
cnt += factor;<br>
ctu32Idx += getCUIndex(&cuLoc, &cnt, factor, 0);<br>
}<br>
@@ -3728,10 +3728,10 @@<br>
<br>
for (int numCTU = 0; numCTU < numCTUCopied; numCTU++)<br>
{<br>
- memset(&((analysis_inter_data *)analysis->interData)->depth[<wbr>count], writeDepth, bytes);<br>
- memset(&((analysis_inter_data *)analysis->interData)->modes[<wbr>count], modeBuf[d], bytes);<br>
+ memset(&(analysis->interData)-<wbr>>depth[count], writeDepth, bytes);<br>
+ memset(&(analysis->interData)-<wbr>>modes[count], modeBuf[d], bytes);<br>
if (m_param->analysisReuseLevel == 10 && bIntraInInter)<br>
- memset(&((analysis_intra_data *)analysis->intraData)-><wbr>chromaModes[count], chromaDir[d], bytes);<br>
+ memset(&(analysis->intraData)-<wbr>>chromaModes[count], chromaDir[d], bytes);<br>
<br>
if (m_param->analysisReuseLevel > 4)<br>
{<br>
@@ -3742,7 +3742,7 @@<br>
int partitionSize = partSize[d];<br>
if (isScaledMaxCUSize && partSize[d] != SIZE_2Nx2N)<br>
partitionSize = getPuShape(&puOrient, partSize[d], numCTU);<br>
- memset(&((analysis_inter_data *)analysis->interData)-><wbr>partSize[count], partitionSize, bytes);<br>
+ memset(&(analysis->interData)-<wbr>>partSize[count], partitionSize, bytes);<br>
int numPU = (modeBuf[d] == MODE_INTRA) ? 1 : nbPartsTable[(int)partSize[d]]<wbr>;<br>
for (int pu = 0; pu < numPU; pu++)<br>
{<br>
@@ -3758,18 +3758,18 @@<br>
if (puOrient.isAmp && pu)<br>
d++;<br>
<br>
- ((analysis_inter_data *)analysis->interData)-><wbr>mergeFlag[count + pu] = mergeFlag[d];<br>
+ (analysis->interData)-><wbr>mergeFlag[count + pu] = mergeFlag[d];<br>
if (m_param->analysisReuseLevel == 10)<br>
{<br>
- ((analysis_inter_data *)analysis->interData)-><wbr>interDir[count + pu] = interDir[d];<br>
+ (analysis->interData)-><wbr>interDir[count + pu] = interDir[d];<br>
MV mvCopy[2];<br>
for (uint32_t i = 0; i < numDir; i++)<br>
{<br>
- ((analysis_inter_data *)analysis->interData)-><wbr>mvpIdx[i][count + pu] = mvpIdx[i][d];<br>
- ((analysis_inter_data *)analysis->interData)-><wbr>refIdx[i][count + pu] = refIdx[i][d];<br>
+ (analysis->interData)->mvpIdx[<wbr>i][count + pu] = mvpIdx[i][d];<br>
+ (analysis->interData)->refIdx[<wbr>i][count + pu] = refIdx[i][d];<br>
mvCopy[i].x = mv[i][d].x * (int16_t)m_param->scaleFactor;<br>
mvCopy[i].y = mv[i][d].y * (int16_t)m_param->scaleFactor;<br>
- memcpy(&((analysis_inter_data *)analysis->interData)->mv[i][<wbr>count + pu], &mvCopy[i], sizeof(MV));<br>
+ memcpy(&(analysis->interData)-<wbr>>mv[i][count + pu], &mvCopy[i], sizeof(MV));<br>
}<br>
}<br>
d = restoreD; // Restore d value after copying each of the 4 64x64 CTUs<br>
@@ -3810,7 +3810,7 @@<br>
uint32_t cnt = 0;<br>
for (uint32_t ctu32Idx = 0; ctu32Idx < analysis->numCUsInFrame * scaledNumPartition; ctu32Idx++)<br>
{<br>
- memset(&((analysis_intra_data *)analysis->intraData)->modes[<wbr>cnt], tempLumaBuf[ctu32Idx], factor);<br>
+ memset(&(analysis->intraData)-<wbr>>modes[cnt], tempLumaBuf[ctu32Idx], factor);<br>
cnt += factor;<br>
ctu32Idx += getCUIndex(&cuLoc, &cnt, factor, 0);<br>
}<br>
@@ -3818,7 +3818,7 @@<br>
}<br>
}<br>
else<br>
- X265_FREAD(((analysis_inter_<wbr>data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFileIn, interPic->ref);<br>
+ X265_FREAD((analysis-><wbr>interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFileIn, interPic->ref);<br>
<br>
consumedBytes += frameRecordSize;<br>
if (numDir == 1)<br>
@@ -4078,9 +4078,9 @@<br>
depthBuf = tempBuf;<br>
distortionBuf = tempdistBuf;<br>
x265_analysis_data *analysisData = (x265_analysis_data*)analysis;<br>
- analysis_intra_data *intraData = (analysis_intra_data *)analysisData->intraData;<br>
- analysis_inter_data *interData = (analysis_inter_data *)analysisData->interData;<br>
- analysisDistortionData *distortionData = (analysisDistortionData *)analysisData-><wbr>distortionData;<br>
+ x265_analysis_intra_data *intraData = analysisData->intraData;<br>
+ x265_analysis_inter_data *interData = analysisData->interData;<br>
+ x265_analysis_distortion_data *distortionData = analysisData->distortionData;<br>
<br>
size_t count = 0;<br>
uint32_t ctuCount = 0;<br>
@@ -4147,15 +4147,15 @@<br>
size_t bytes = analysis->numPartitions >> (depthBuf[d] * 2);<br>
for (int i = 0; i < numDir; i++)<br>
{<br>
- int32_t* ref = &((analysis_inter_data*)<wbr>analysis->interData)->ref[i * analysis->numPartitions * analysis->numCUsInFrame];<br>
+ int32_t* ref = &(analysis->interData)->ref[i * analysis->numPartitions * analysis->numCUsInFrame];<br>
for (size_t j = count, k = 0; k < bytes; j++, k++)<br>
{<br>
- memcpy(&((analysis_inter_data*<wbr>)analysis->interData)->mv[i][<wbr>j], MVBuf[i] + d, sizeof(MV));<br>
- memcpy(&((analysis_inter_data*<wbr>)analysis->interData)->mvpIdx[<wbr>i][j], mvpBuf[i] + d, sizeof(uint8_t));<br>
+ memcpy(&(analysis->interData)-<wbr>>mv[i][j], MVBuf[i] + d, sizeof(MV));<br>
+ memcpy(&(analysis->interData)-<wbr>>mvpIdx[i][j], mvpBuf[i] + d, sizeof(uint8_t));<br>
memcpy(&ref[j], refBuf + (i * depthBytes) + d, sizeof(int32_t));<br>
}<br>
}<br>
- memset(&((analysis_inter_data *)analysis->interData)->modes[<wbr>count], modeBuf[d], bytes);<br>
+ memset(&(analysis->interData)-<wbr>>modes[count], modeBuf[d], bytes);<br>
count += bytes;<br>
}<br>
<br>
@@ -4219,7 +4219,7 @@<br>
uint8_t partSize = 0;<br>
<br>
CUData* ctu = curEncData.getPicCTU(cuAddr);<br>
- analysis_intra_data* intraDataCTU = (analysis_intra_data*)<wbr>analysis->intraData;<br>
+ x265_analysis_intra_data* intraDataCTU = analysis->intraData;<br>
<br>
for (uint32_t absPartIdx = 0; absPartIdx < ctu->m_numPartitions; depthBytes++)<br>
{<br>
@@ -4247,8 +4247,8 @@<br>
uint8_t partSize = 0;<br>
<br>
CUData* ctu = curEncData.getPicCTU(cuAddr);<br>
- analysis_inter_data* interDataCTU = (analysis_inter_data*)<wbr>analysis->interData;<br>
- analysis_intra_data* intraDataCTU = (analysis_intra_data*)<wbr>analysis->intraData;<br>
+ x265_analysis_inter_data* interDataCTU = analysis->interData;<br>
+ x265_analysis_intra_data* intraDataCTU = analysis->intraData;<br>
<br>
for (uint32_t absPartIdx = 0; absPartIdx < ctu->m_numPartitions; depthBytes++)<br>
{<br>
@@ -4281,7 +4281,9 @@<br>
{<br>
interDataCTU->mvpIdx[dir][<wbr>depthBytes] = ctu->m_mvpIdx[dir][<wbr>puabsPartIdx];<br>
interDataCTU->refIdx[dir][<wbr>depthBytes] = ctu->m_refIdx[dir][<wbr>puabsPartIdx];<br>
- interDataCTU->mv[dir][<wbr>depthBytes] = ctu->m_mv[dir][puabsPartIdx];<br>
+ interDataCTU->mv[dir][<wbr>depthBytes].x = ctu->m_mv[dir][puabsPartIdx].<wbr>x;<br>
+ interDataCTU->mv[dir][<wbr>depthBytes].y = ctu->m_mv[dir][puabsPartIdx].<wbr>y;<br>
+ interDataCTU->mv[dir][<wbr>depthBytes].word = ctu->m_mv[dir][puabsPartIdx].<wbr>word;<br>
}<br>
}<br>
}<br>
@@ -4339,35 +4341,35 @@<br>
<br>
if (analysis->sliceType == X265_TYPE_IDR || analysis->sliceType == X265_TYPE_I)<br>
{<br>
- X265_FWRITE(((analysis_intra_<wbr>data*)analysis->intraData)-><wbr>depth, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
- X265_FWRITE(((analysis_intra_<wbr>data*)analysis->intraData)-><wbr>chromaModes, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
- X265_FWRITE(((analysis_intra_<wbr>data*)analysis->intraData)-><wbr>partSizes, sizeof(char), depthBytes, m_analysisFileOut);<br>
- X265_FWRITE(((analysis_intra_<wbr>data*)analysis->intraData)-><wbr>modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFileOut);<br>
+ X265_FWRITE((analysis-><wbr>intraData)->depth, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
+ X265_FWRITE((analysis-><wbr>intraData)->chromaModes, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
+ X265_FWRITE((analysis-><wbr>intraData)->partSizes, sizeof(char), depthBytes, m_analysisFileOut);<br>
+ X265_FWRITE((analysis-><wbr>intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFileOut);<br>
}<br>
else<br>
{<br>
- X265_FWRITE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>depth, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
- X265_FWRITE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>modes, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
+ X265_FWRITE((analysis-><wbr>interData)->depth, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
+ X265_FWRITE((analysis-><wbr>interData)->modes, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
if (m_param->analysisReuseLevel > 4)<br>
{<br>
- X265_FWRITE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>partSize, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
- X265_FWRITE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>mergeFlag, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
+ X265_FWRITE((analysis-><wbr>interData)->partSize, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
+ X265_FWRITE((analysis-><wbr>interData)->mergeFlag, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
if (m_param->analysisReuseLevel == 10)<br>
{<br>
- X265_FWRITE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>interDir, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
- if (bIntraInInter) X265_FWRITE(((analysis_intra_<wbr>data*)analysis->intraData)-><wbr>chromaModes, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
+ X265_FWRITE((analysis-><wbr>interData)->interDir, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
+ if (bIntraInInter) X265_FWRITE((analysis-><wbr>intraData)->chromaModes, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
for (uint32_t dir = 0; dir < numDir; dir++)<br>
{<br>
- X265_FWRITE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>mvpIdx[dir], sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
- X265_FWRITE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>refIdx[dir], sizeof(int8_t), depthBytes, m_analysisFileOut);<br>
- X265_FWRITE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>mv[dir], sizeof(MV), depthBytes, m_analysisFileOut);<br>
+ X265_FWRITE((analysis-><wbr>interData)->mvpIdx[dir], sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
+ X265_FWRITE((analysis-><wbr>interData)->refIdx[dir], sizeof(int8_t), depthBytes, m_analysisFileOut);<br>
+ X265_FWRITE((analysis-><wbr>interData)->mv[dir], sizeof(MV), depthBytes, m_analysisFileOut);<br>
}<br>
if (bIntraInInter)<br>
- X265_FWRITE(((analysis_intra_<wbr>data*)analysis->intraData)-><wbr>modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFileOut);<br>
+ X265_FWRITE((analysis-><wbr>intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFileOut);<br>
}<br>
}<br>
if (m_param->analysisReuseLevel != 10)<br>
- X265_FWRITE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFileOut);<br>
+ X265_FWRITE((analysis-><wbr>interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFileOut);<br>
<br>
}<br>
#undef X265_FWRITE<br>
@@ -4386,10 +4388,9 @@<br>
<br>
uint32_t depthBytes = 0;<br>
x265_analysis_data *analysisData = (x265_analysis_data*)analysis;<br>
- analysis_intra_data *intraData = (analysis_intra_data *)analysisData->intraData;<br>
- analysis_inter_data *interData = (analysis_inter_data *)analysisData->interData;<br>
- analysisDistortionData *distortionData = (analysisDistortionData *)analysisData-><wbr>distortionData;<br>
- <br>
+ x265_analysis_intra_data *intraData = analysisData->intraData;<br>
+ x265_analysis_inter_data *interData = analysisData->interData;<br>
+ x265_analysis_distortion_data *distortionData = analysisData->distortionData;<br>
<br>
for (uint32_t cuAddr = 0; cuAddr < analysis->numCUsInFrame; cuAddr++)<br>
{<br>
@@ -4412,8 +4413,8 @@<br>
if (curEncData.m_slice->m_<wbr>sliceType != I_SLICE)<br>
{<br>
int32_t* ref[2];<br>
- ref[0] = ((analysis_inter_data*)<wbr>analysis->interData)->ref;<br>
- ref[1] = &((analysis_inter_data*)<wbr>analysis->interData)->ref[<wbr>analysis->numPartitions * analysis->numCUsInFrame];<br>
+ ref[0] = (analysis->interData)->ref;<br>
+ ref[1] = &(analysis->interData)->ref[<wbr>analysis->numPartitions * analysis->numCUsInFrame];<br>
depthBytes = 0;<br>
for (uint32_t cuAddr = 0; cuAddr < analysis->numCUsInFrame; cuAddr++)<br>
{<br>
@@ -4424,13 +4425,17 @@<br>
for (uint32_t absPartIdx = 0; absPartIdx < ctu->m_numPartitions; depthBytes++)<br>
{<br>
depth = ctu->m_cuDepth[absPartIdx];<br>
- interData->mv[0][depthBytes] = ctu->m_mv[0][absPartIdx];<br>
+ interData->mv[0][depthBytes].x = ctu->m_mv[0][absPartIdx].x;<br>
+ interData->mv[0][depthBytes].y = ctu->m_mv[0][absPartIdx].y;<br>
+ interData->mv[0][depthBytes].<wbr>word = ctu->m_mv[0][absPartIdx].word;<br>
interData->mvpIdx[0][<wbr>depthBytes] = ctu->m_mvpIdx[0][absPartIdx];<br>
ref[0][depthBytes] = ctu->m_refIdx[0][absPartIdx];<br>
predMode = ctu->m_predMode[absPartIdx];<br>
if (ctu->m_refIdx[1][absPartIdx] != -1)<br>
{<br>
- interData->mv[1][depthBytes] = ctu->m_mv[1][absPartIdx];<br>
+ interData->mv[1][depthBytes].x = ctu->m_mv[1][absPartIdx].x;<br>
+ interData->mv[1][depthBytes].y = ctu->m_mv[1][absPartIdx].y;<br>
+ interData->mv[1][depthBytes].<wbr>word = ctu->m_mv[1][absPartIdx].word;<br>
interData->mvpIdx[1][<wbr>depthBytes] = ctu->m_mvpIdx[1][absPartIdx];<br>
ref[1][depthBytes] = ctu->m_refIdx[1][absPartIdx];<br>
predMode = 4; // used as indiacator if the block is coded as bidir<br>
@@ -4459,11 +4464,11 @@<br>
X265_FWRITE(&analysis->poc, sizeof(uint32_t), 1, m_analysisFileOut);<br>
if (curEncData.m_slice->m_<wbr>sliceType == I_SLICE)<br>
{<br>
- X265_FWRITE(((analysis_intra_<wbr>data*)analysis->intraData)-><wbr>depth, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
+ X265_FWRITE((analysis-><wbr>intraData)->depth, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
}<br>
else<br>
{<br>
- X265_FWRITE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>depth, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
+ X265_FWRITE((analysis-><wbr>interData)->depth, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
}<br>
X265_FWRITE(distortionData-><wbr>distortion, sizeof(sse_t), depthBytes, m_analysisFileOut);<br>
if (curEncData.m_slice->m_<wbr>sliceType != I_SLICE)<br>
@@ -4471,12 +4476,12 @@<br>
int numDir = curEncData.m_slice->m_<wbr>sliceType == P_SLICE ? 1 : 2;<br>
for (int i = 0; i < numDir; i++)<br>
{<br>
- int32_t* ref = &((analysis_inter_data*)<wbr>analysis->interData)->ref[i * analysis->numPartitions * analysis->numCUsInFrame];<br>
+ int32_t* ref = &(analysis->interData)->ref[i * analysis->numPartitions * analysis->numCUsInFrame];<br>
X265_FWRITE(interData->mv[i], sizeof(MV), depthBytes, m_analysisFileOut);<br>
X265_FWRITE(interData->mvpIdx[<wbr>i], sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
X265_FWRITE(ref, sizeof(int32_t), depthBytes, m_analysisFileOut);<br>
}<br>
- X265_FWRITE(((analysis_inter_<wbr>data*)analysis->interData)-><wbr>modes, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
+ X265_FWRITE((analysis-><wbr>interData)->modes, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>
}<br>
#undef X265_FWRITE<br>
}<br>
diff -r fb1530b0e1b4 -r 9694dfbe83ac source/encoder/search.cpp<br>
--- a/source/encoder/search.cpp Fri Jul 20 14:20:22 2018 +0530<br>
+++ b/source/encoder/search.cpp Fri Jul 20 14:03:53 2018 +0530<br>
@@ -2178,12 +2178,12 @@<br>
PredictionUnit pu(cu, cuGeom, puIdx);<br>
m_me.setSourcePU(*interMode.<wbr>fencYuv, pu.ctuAddr, pu.cuAbsPartIdx, pu.puAbsPartIdx, pu.width, pu.height, m_param->searchMethod, m_param->subpelRefine, bChromaMC);<br>
useAsMVP = false;<br>
- analysis_inter_data* interDataCTU = NULL;<br>
+ x265_analysis_inter_data* interDataCTU = NULL;<br>
int cuIdx;<br>
cuIdx = (interMode.cu.m_cuAddr * m_param->num4x4Partitions) + cuGeom.absPartIdx;<br>
if (m_param->analysisReuseLevel == 10 && m_param->interRefine > 1)<br>
{<br>
- interDataCTU = (analysis_inter_data*)m_frame-<wbr>>m_analysisData.interData;<br>
+ interDataCTU = m_frame->m_analysisData.<wbr>interData;<br>
if ((cu.m_predMode[pu.<wbr>puAbsPartIdx] == interDataCTU->modes[cuIdx + pu.puAbsPartIdx])<br>
&& (cu.m_partSize[pu.<wbr>puAbsPartIdx] == interDataCTU->partSize[cuIdx + pu.puAbsPartIdx])<br>
&& !(interDataCTU->mergeFlag[<wbr>cuIdx + puIdx])<br>
@@ -2225,7 +2225,9 @@<br>
MV mvmin, mvmax, outmv, mvp;<br>
if (useAsMVP)<br>
{<br>
- mvp = interDataCTU->mv[list][cuIdx + puIdx];<br>
+ mvp.x = interDataCTU->mv[list][cuIdx + puIdx].x;<br>
+ mvp.y = interDataCTU->mv[list][cuIdx + puIdx].y;<br>
+ mvp.word = interDataCTU->mv[list][cuIdx + puIdx].word;<br>
mvpIdx = interDataCTU->mvpIdx[list][<wbr>cuIdx + puIdx];<br>
}<br>
else<br>
diff -r fb1530b0e1b4 -r 9694dfbe83ac source/x265.h<br>
--- a/source/x265.h Fri Jul 20 14:20:22 2018 +0530<br>
+++ b/source/x265.h Fri Jul 20 14:03:53 2018 +0530<br>
@@ -26,11 +26,16 @@<br>
#define X265_H<br>
#include <stdint.h><br>
#include <stdio.h><br>
+#include <stdbool.h><br>
#include "x265_config.h"<br>
#ifdef __cplusplus<br>
extern "C" {<br>
#endif<br>
<br>
+#if _MSC_VER<br>
+#pragma warning(disable: 4201) // non-standard extension used (nameless struct/union)<br>
+#endif<br>
+<br>
/* x265_encoder:<br>
* opaque handler for encoder */<br>
typedef struct x265_encoder x265_encoder;<br>
@@ -127,25 +132,85 @@<br>
int chunkEnd;<br>
}x265_analysis_validate;<br>
<br>
+/* Stores intra analysis data for a single frame. This struct needs better packing */<br>
+typedef struct x265_analysis_intra_data<br>
+{<br>
+ uint8_t* depth;<br>
+ uint8_t* modes;<br>
+ char* partSizes;<br>
+ uint8_t* chromaModes;<br>
+}x265_analysis_intra_data;<br>
+<br>
+typedef struct x265_analysis_MV<br>
+{<br>
+ union{<br>
+ struct { int16_t x, y; };<br>
+<br>
+ int32_t word;<br>
+ };<br>
+}x265_analysis_MV;<br>
+<br>
+/* Stores inter analysis data for a single frame */<br>
+typedef struct x265_analysis_inter_data<br>
+{<br>
+ int32_t* ref;<br>
+ uint8_t* depth;<br>
+ uint8_t* modes;<br>
+ uint8_t* partSize;<br>
+ uint8_t* mergeFlag;<br>
+ uint8_t* interDir;<br>
+ uint8_t* mvpIdx[2];<br>
+ int8_t* refIdx[2];<br>
+ x265_analysis_MV* mv[2];<br>
+ int64_t* sadCost;<br>
+}x265_analysis_inter_data;<br>
+<br>
+typedef struct x265_weight_param<br>
+{<br>
+ uint32_t log2WeightDenom;<br>
+ int inputWeight;<br>
+ int inputOffset;<br>
+ bool bPresentFlag;<br>
+}x265_weight_param;<br>
+<br>
+#if X265_DEPTH < 10<br>
+typedef uint32_t sse_t;<br>
+#else<br>
+typedef uint64_t sse_t;<br>
+#endif<br>
+<br>
+typedef struct x265_analysis_distortion_data<br>
+{<br>
+ sse_t* distortion;<br>
+ sse_t* ctuDistortion;<br>
+ double* scaledDistortion;<br>
+ double averageDistortion;<br>
+ double sdDistortion;<br>
+ uint32_t highDistortionCtuCount;<br>
+ uint32_t lowDistortionCtuCount;<br>
+ double* offset;<br>
+ double* threshold;<br>
+}x265_analysis_distortion_<wbr>data;<br>
+<br>
/* Stores all analysis data for a single frame */<br>
typedef struct x265_analysis_data<br>
{<br>
- int64_t satdCost;<br>
- uint32_t frameRecordSize;<br>
- uint32_t poc;<br>
- uint32_t sliceType;<br>
- uint32_t numCUsInFrame;<br>
- uint32_t numPartitions;<br>
- uint32_t depthBytes;<br>
- int bScenecut;<br>
- void* wt;<br>
- void* interData;<br>
- void* intraData;<br>
- uint32_t numCuInHeight;<br>
- x265_lookahead_data lookahead;<br>
- uint8_t* modeFlag[2];<br>
- x265_analysis_validate saveParam;<br>
- void* distortionData;<br>
+ int64_t satdCost;<br>
+ uint32_t frameRecordSize;<br>
+ uint32_t poc;<br>
+ uint32_t sliceType;<br>
+ uint32_t numCUsInFrame;<br>
+ uint32_t numPartitions;<br>
+ uint32_t depthBytes;<br>
+ int bScenecut;<br>
+ x265_weight_param* wt;<br>
+ x265_analysis_inter_data* interData;<br>
+ x265_analysis_intra_data* intraData;<br>
+ uint32_t numCuInHeight;<br>
+ x265_lookahead_data lookahead;<br>
+ uint8_t* modeFlag[2];<br>
+ x265_analysis_validate saveParam;<br>
+ x265_analysis_distortion_data* distortionData;<br>
} x265_analysis_data;<br>
<br>
/* cu statistics */<br>
@@ -1756,7 +1821,7 @@<br>
/* x265_build_info:<br>
* A static string describing the compiler and target architecture */<br>
X265_API extern const char *x265_build_info_str;<br>
-<br>
+<br>
/* x265_alloc_analysis_data:<br>
* Allocate memory for the x265_analysis_data object's internal structures. */<br>
void x265_alloc_analysis_data(x265_<wbr>param *param, x265_analysis_data* analysis);<br>
<br>______________________________<wbr>_________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/<wbr>listinfo/x265-devel</a><br>
<br></blockquote></div><br></div><div class="gmail_extra">Pushed to default.</div></div>