<div dir="ltr">Ohkay, I see what you did. Reverted my change and pushed in as is. <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 8, 2015 at 5:35 PM, <span dir="ltr"><<a href="mailto:gopu@multicorewareinc.com" target="_blank">gopu@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 Gopu Govindaswamy <<a href="mailto:gopu@multicorewareinc.com">gopu@multicorewareinc.com</a>><br>
# Date 1420713484 -19800<br>
# Thu Jan 08 16:08:04 2015 +0530<br>
# Node ID f307fc02faf6111642737516cf34d3dd5f3b2820<br>
# Parent 24da7b0accdafb1f9e7e54182c114cb264d09bab<br>
analysis: dump the best depth and re-use it for analysis-mode=load<br>
<br>
For inter frame currently sharing the best ref and in addition to that<br>
share the depth and re-use it for analysis mode=load, the best depth can be<br>
shared only if Predmode is MODE_SKIP, otherwise ignored. currently this changes<br>
works only rdlevel > 4<br>
<br>
diff -r 24da7b0accda -r f307fc02faf6 source/common/common.h<br>
--- a/source/common/common.h Wed Dec 24 10:34:59 2014 +0530<br>
+++ b/source/common/common.h Thu Jan 08 16:08:04 2015 +0530<br>
@@ -353,10 +353,12 @@<br>
}<br>
};<br>
<br>
-/* Stores inter (motion estimation) analysis data for a single frame */<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>
};<br>
<br>
/* Stores intra analysis data for a single frame. This struct needs better packing */<br>
diff -r 24da7b0accda -r f307fc02faf6 source/encoder/analysis.cpp<br>
--- a/source/encoder/analysis.cpp Wed Dec 24 10:34:59 2014 +0530<br>
+++ b/source/encoder/analysis.cpp Thu Jan 08 16:08:04 2015 +0530<br>
@@ -143,9 +143,9 @@<br>
}<br>
}<br>
<br>
+ uint32_t zOrder = 0;<br>
if (m_slice->m_sliceType == I_SLICE)<br>
{<br>
- uint32_t zOrder = 0;<br>
compressIntraCU(ctu, cuGeom, zOrder);<br>
if (m_param->analysisMode == X265_ANALYSIS_SAVE && m_frame->m_analysisData.intraData)<br>
{<br>
@@ -173,7 +173,15 @@<br>
else if (m_param->rdLevel <= 4)<br>
compressInterCU_rd0_4(ctu, cuGeom);<br>
else<br>
- compressInterCU_rd5_6(ctu, cuGeom);<br>
+ {<br>
+ compressInterCU_rd5_6(ctu, cuGeom, zOrder);<br>
+ if (m_param->analysisMode == X265_ANALYSIS_SAVE && m_frame->m_analysisData.interData)<br>
+ {<br>
+ CUData *bestCU = &m_modeDepth[0].bestMode->cu;<br>
+ memcpy(&m_reuseInterDataCTU->depth[ctu.m_cuAddr * numPartition], bestCU->m_cuDepth, sizeof(uint8_t) * numPartition);<br>
+ memcpy(&m_reuseInterDataCTU->modes[ctu.m_cuAddr * numPartition], bestCU->m_predMode, sizeof(uint8_t) * numPartition);<br>
+ }<br>
+ }<br>
}<br>
<br>
return *m_modeDepth[0].bestMode;<br>
@@ -1037,7 +1045,7 @@<br>
md.bestMode->reconYuv.copyToPicYuv(*m_frame->m_reconPic, cuAddr, cuGeom.encodeIdx);<br>
}<br>
<br>
-void Analysis::compressInterCU_rd5_6(const CUData& parentCTU, const CUGeom& cuGeom)<br>
+void Analysis::compressInterCU_rd5_6(const CUData& parentCTU, const CUGeom& cuGeom, uint32_t &zOrder)<br>
{<br>
uint32_t depth = cuGeom.depth;<br>
ModeDepth& md = m_modeDepth[depth];<br>
@@ -1046,6 +1054,45 @@<br>
bool mightSplit = !(cuGeom.flags & CUGeom::LEAF);<br>
bool mightNotSplit = !(cuGeom.flags & CUGeom::SPLIT_MANDATORY);<br>
<br>
+ if (m_param->analysisMode == X265_ANALYSIS_LOAD)<br>
+ {<br>
+ uint8_t* reuseDepth = &m_reuseInterDataCTU->depth[parentCTU.m_cuAddr * parentCTU.m_numPartitions];<br>
+ uint8_t* reuseModes = &m_reuseInterDataCTU->modes[parentCTU.m_cuAddr * parentCTU.m_numPartitions];<br>
+ if (mightNotSplit && depth == reuseDepth[zOrder] && zOrder == cuGeom.encodeIdx && reuseModes[zOrder] == MODE_SKIP)<br>
+ {<br>
+ md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom);<br>
+ md.pred[PRED_MERGE].cu.initSubCU(parentCTU, cuGeom);<br>
+ checkMerge2Nx2N_rd5_6(md.pred[PRED_SKIP], md.pred[PRED_MERGE], cuGeom);<br>
+<br>
+ if ((m_slice->m_sliceType != B_SLICE || m_param->bIntraInBFrames) &&<br>
+ (!m_param->bEnableCbfFastMode || md.bestMode->cu.getQtRootCbf(0)))<br>
+ {<br>
+ md.pred[PRED_INTRA].cu.initSubCU(parentCTU, cuGeom);<br>
+ checkIntra(md.pred[PRED_INTRA], cuGeom, SIZE_2Nx2N, NULL);<br>
+ checkBestMode(md.pred[PRED_INTRA], depth);<br>
+<br>
+ if (depth == g_maxCUDepth && cuGeom.log2CUSize > m_slice->m_sps->quadtreeTULog2MinSize)<br>
+ {<br>
+ md.pred[PRED_INTRA_NxN].cu.initSubCU(parentCTU, cuGeom);<br>
+ checkIntra(md.pred[PRED_INTRA_NxN], cuGeom, SIZE_NxN, &reuseModes[zOrder]);<br>
+ checkBestMode(md.pred[PRED_INTRA_NxN], depth);<br>
+ }<br>
+ }<br>
+<br>
+ if (m_bTryLossless)<br>
+ tryLossless(cuGeom);<br>
+<br>
+ if (mightSplit)<br>
+ addSplitFlagCost(*md.bestMode, cuGeom.depth);<br>
+<br>
+ // increment zOrder offset to point to next best depth in sharedDepth buffer<br>
+ zOrder += g_depthInc[g_maxCUDepth - 1][reuseDepth[zOrder]];<br>
+<br>
+ mightSplit = false;<br>
+ mightNotSplit = false;<br>
+ }<br>
+ }<br>
+<br>
if (mightNotSplit)<br>
{<br>
md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom);<br>
@@ -1177,7 +1224,7 @@<br>
{<br>
m_modeDepth[0].fencYuv.copyPartToYuv(nd.fencYuv, childGeom.encodeIdx);<br>
m_rqt[nextDepth].cur.load(*nextContext);<br>
- compressInterCU_rd5_6(parentCTU, childGeom);<br>
+ compressInterCU_rd5_6(parentCTU, childGeom, zOrder);<br>
<br>
// Save best CU and pred data for this sub CU<br>
splitCU->copyPartFrom(nd.bestMode->cu, childGeom, subPartIdx);<br>
@@ -1186,7 +1233,10 @@<br>
nextContext = &nd.bestMode->contexts;<br>
}<br>
else<br>
+ {<br>
splitCU->setEmptyPart(childGeom, subPartIdx);<br>
+ zOrder += g_depthInc[g_maxCUDepth - 1][nextDepth];<br>
+ }<br>
}<br>
nextContext->store(splitPred->contexts);<br>
if (mightNotSplit)<br>
diff -r 24da7b0accda -r f307fc02faf6 source/encoder/analysis.h<br>
--- a/source/encoder/analysis.h Wed Dec 24 10:34:59 2014 +0530<br>
+++ b/source/encoder/analysis.h Thu Jan 08 16:08:04 2015 +0530<br>
@@ -101,7 +101,7 @@<br>
/* full analysis for a P or B slice CU */<br>
void compressInterCU_dist(const CUData& parentCTU, const CUGeom& cuGeom);<br>
void compressInterCU_rd0_4(const CUData& parentCTU, const CUGeom& cuGeom);<br>
- void compressInterCU_rd5_6(const CUData& parentCTU, const CUGeom& cuGeom);<br>
+ void compressInterCU_rd5_6(const CUData& parentCTU, const CUGeom& cuGeom, uint32_t &zOrder);<br>
<br>
/* measure merge and skip */<br>
void checkMerge2Nx2N_rd0_4(Mode& skip, Mode& merge, const CUGeom& cuGeom);<br>
diff -r 24da7b0accda -r f307fc02faf6 source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Wed Dec 24 10:34:59 2014 +0530<br>
+++ b/source/encoder/encoder.cpp Thu Jan 08 16:08:04 2015 +0530<br>
@@ -1578,6 +1578,8 @@<br>
analysis_inter_data *interData = (analysis_inter_data*)analysis->interData;<br>
CHECKED_MALLOC_ZERO(interData, analysis_inter_data, 1);<br>
CHECKED_MALLOC(interData->ref, int32_t, analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2);<br>
+ CHECKED_MALLOC(interData->depth, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
+ CHECKED_MALLOC(interData->modes, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
analysis->interData = interData;<br>
}<br>
return;<br>
@@ -1599,6 +1601,8 @@<br>
else<br>
{<br>
X265_FREE(((analysis_inter_data*)analysis->interData)->ref);<br>
+ X265_FREE(((analysis_inter_data*)analysis->interData)->depth);<br>
+ X265_FREE(((analysis_inter_data*)analysis->interData)->modes);<br>
X265_FREE(analysis->interData);<br>
}<br>
}<br>
@@ -1662,12 +1666,16 @@<br>
else if (analysis->sliceType == X265_TYPE_P)<br>
{<br>
X265_FREAD(((analysis_inter_data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU, m_analysisFile);<br>
+ X265_FREAD(((analysis_inter_data *)analysis->interData)->depth, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFile);<br>
+ X265_FREAD(((analysis_inter_data *)analysis->interData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFile);<br>
consumedBytes += frameRecordSize;<br>
totalConsumedBytes = consumedBytes;<br>
}<br>
else<br>
{<br>
X265_FREAD(((analysis_inter_data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2, m_analysisFile);<br>
+ X265_FREAD(((analysis_inter_data *)analysis->interData)->depth, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFile);<br>
+ X265_FREAD(((analysis_inter_data *)analysis->interData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFile);<br>
consumedBytes += frameRecordSize;<br>
}<br>
#undef X265_FREAD<br>
@@ -1691,9 +1699,15 @@<br>
if (analysis->sliceType == X265_TYPE_IDR || analysis->sliceType == X265_TYPE_I)<br>
analysis->frameRecordSize += sizeof(uint8_t) * analysis->numCUsInFrame * analysis->numPartitions * 3;<br>
else if (analysis->sliceType == X265_TYPE_P)<br>
+ {<br>
analysis->frameRecordSize += sizeof(int32_t) * analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU;<br>
+ analysis->frameRecordSize += sizeof(uint8_t) * analysis->numCUsInFrame * analysis->numPartitions * 2;<br>
+ }<br>
else<br>
+ {<br>
analysis->frameRecordSize += sizeof(int32_t) * analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2;<br>
+ analysis->frameRecordSize += sizeof(uint8_t) * analysis->numCUsInFrame * analysis->numPartitions * 2;<br>
+ }<br>
<br>
X265_FWRITE(&analysis->frameRecordSize, sizeof(uint32_t), 1, m_analysisFile);<br>
X265_FWRITE(&analysis->poc, sizeof(int), 1, m_analysisFile);<br>
@@ -1709,11 +1723,15 @@<br>
}<br>
else if (analysis->sliceType == X265_TYPE_P)<br>
{<br>
- X265_FWRITE(((analysis_inter_data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU, m_analysisFile);<br>
+ X265_FWRITE(((analysis_inter_data*)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU, m_analysisFile);<br>
+ X265_FWRITE(((analysis_inter_data*)analysis->interData)->depth, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFile);<br>
+ X265_FWRITE(((analysis_inter_data*)analysis->interData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFile);<br>
}<br>
else<br>
{<br>
- X265_FWRITE(((analysis_inter_data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2, m_analysisFile);<br>
+ X265_FWRITE(((analysis_inter_data*)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2, m_analysisFile);<br>
+ X265_FWRITE(((analysis_inter_data*)analysis->interData)->depth, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFile);<br>
+ X265_FWRITE(((analysis_inter_data*)analysis->interData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFile);<br>
}<br>
#undef X265_FWRITE<br>
}<br>
_______________________________________________<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" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br></div>