<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 24, 2014 at 10:35 AM, <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 1419397499 -19800<br>
# Wed Dec 24 10:34:59 2014 +0530<br>
# Node ID f75dc9609ebc8a6ca32921b352a55831e7dd199e<br>
# Parent 5f9f7194267b76f733e9ffb0f9e8b474dfe89a71<br>
analysis: simplify inter analysis structure to share more inter analysis data<br>
<br>
diff -r 5f9f7194267b -r f75dc9609ebc source/common/common.h<br>
--- a/source/common/common.h Tue Dec 23 17:40:53 2014 +0900<br>
+++ b/source/common/common.h Wed Dec 24 10:34:59 2014 +0530<br>
@@ -362,7 +362,7 @@<br>
/* Stores inter (motion estimation) analysis data for a single frame */<br>
struct analysis_inter_data<br>
{<br>
- int ref;<br>
+ int32_t* ref;<br>
};<br>
<br>
/* Stores intra analysis data for a single frame. This struct needs better packing */<br>
diff -r 5f9f7194267b -r f75dc9609ebc source/encoder/analysis.cpp<br>
--- a/source/encoder/analysis.cpp Tue Dec 23 17:40:53 2014 +0900<br>
+++ b/source/encoder/analysis.cpp Wed Dec 24 10:34:59 2014 +0530<br>
@@ -133,9 +133,14 @@<br>
uint32_t numPartition = ctu.m_numPartitions;<br>
if (m_param->analysisMode)<br>
{<br>
- m_reuseIntraDataCTU = (analysis_intra_data *)m_frame->m_analysisData.intraData;<br>
- int numPredDir = m_slice->isInterP() ? 1 : 2;<br>
- m_reuseInterDataCTU = (analysis_inter_data *)m_frame->m_analysisData.interData + ctu.m_cuAddr * X265_MAX_PRED_MODE_PER_CTU * numPredDir;<br>
+ if (m_slice->m_sliceType == I_SLICE)<br>
+ m_reuseIntraDataCTU = (analysis_intra_data *)m_frame->m_analysisData.intraData;<br>
+ else<br>
+ {<br>
+ int numPredDir = m_slice->isInterP() ? 1 : 2;<br>
+ m_reuseInterDataCTU = (analysis_inter_data *)m_frame->m_analysisData.interData;<br>
+ reuseRef = &m_reuseInterDataCTU->ref[ctu.m_cuAddr * X265_MAX_PRED_MODE_PER_CTU * numPredDir];<br>
+ }<br>
}<br>
<br>
if (m_slice->m_sliceType == I_SLICE)<br>
@@ -1437,8 +1442,8 @@<br>
MotionData* bestME = interMode.bestME[part];<br>
for (int32_t i = 0; i < numPredDir; i++)<br>
{<br>
- bestME[i].ref = m_reuseInterDataCTU->ref;<br>
- m_reuseInterDataCTU++;<br>
+ bestME[i].ref = *reuseRef;<br>
+ reuseRef++;<br>
}<br>
}<br>
}<br>
@@ -1465,8 +1470,8 @@<br>
MotionData* bestME = interMode.bestME[puIdx];<br>
for (int32_t i = 0; i < numPredDir; i++)<br>
{<br>
- m_reuseInterDataCTU->ref = bestME[i].ref;<br>
- m_reuseInterDataCTU++;<br>
+ *reuseRef = bestME[i].ref;<br>
+ reuseRef++;<br>
}<br>
}<br>
}<br>
@@ -1492,8 +1497,8 @@<br>
MotionData* bestME = interMode.bestME[puIdx];<br>
for (int32_t i = 0; i < numPredDir; i++)<br>
{<br>
- bestME[i].ref = m_reuseInterDataCTU->ref;<br>
- m_reuseInterDataCTU++;<br>
+ bestME[i].ref = *reuseRef;<br>
+ reuseRef++;<br>
}<br>
}<br>
}<br>
@@ -1509,8 +1514,8 @@<br>
MotionData* bestME = interMode.bestME[puIdx];<br>
for (int32_t i = 0; i < numPredDir; i++)<br>
{<br>
- m_reuseInterDataCTU->ref = bestME[i].ref;<br>
- m_reuseInterDataCTU++;<br>
+ *reuseRef = bestME[i].ref;<br>
+ reuseRef++;<br>
}<br>
}<br>
}<br>
diff -r 5f9f7194267b -r f75dc9609ebc source/encoder/analysis.h<br>
--- a/source/encoder/analysis.h Tue Dec 23 17:40:53 2014 +0900<br>
+++ b/source/encoder/analysis.h Wed Dec 24 10:34:59 2014 +0530<br>
@@ -77,6 +77,7 @@<br>
/* Analysis data for load/save modes, keeps getting incremented as CTU analysis proceeds and data is consumed or read */<br>
analysis_intra_data* m_reuseIntraDataCTU;<br>
analysis_inter_data* m_reuseInterDataCTU;<br>
+ int32_t* reuseRef;<br></blockquote><div><br></div><div>I see what you're doing here. This pointer keeps track of how many references Analysis has consumed. It'd be better to keep do this via a counter. We also need to think about how to make analysis-load/save compatible with pmode. <br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Analysis();<br>
bool create(ThreadLocalData* tld);<br>
void destroy();<br>
diff -r 5f9f7194267b -r f75dc9609ebc source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Tue Dec 23 17:40:53 2014 +0900<br>
+++ b/source/encoder/encoder.cpp Wed Dec 24 10:34:59 2014 +0530<br>
@@ -1570,7 +1570,8 @@<br>
else<br>
{<br>
analysis_inter_data *interData = (analysis_inter_data*)analysis->interData;<br>
- CHECKED_MALLOC(interData, analysis_inter_data, analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2);<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>
analysis->interData = interData;<br>
}<br>
return;<br>
@@ -1590,7 +1591,10 @@<br>
X265_FREE(analysis->intraData);<br>
}<br>
else<br>
+ {<br>
+ X265_FREE(((analysis_inter_data*)analysis->interData)->ref);<br>
X265_FREE(analysis->interData);<br>
+ }<br>
}<br>
<br>
void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc)<br>
@@ -1651,13 +1655,13 @@<br>
}<br>
else if (analysis->sliceType == X265_TYPE_P)<br>
{<br>
- X265_FREAD(analysis->interData, sizeof(analysis_inter_data), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU, m_analysisFile);<br>
+ X265_FREAD(((analysis_inter_data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU, m_analysisFile);<br>
consumedBytes += frameRecordSize;<br>
totalConsumedBytes = consumedBytes;<br>
}<br>
else<br>
{<br>
- X265_FREAD(analysis->interData, sizeof(analysis_inter_data), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2, m_analysisFile);<br>
+ X265_FREAD(((analysis_inter_data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2, m_analysisFile);<br>
consumedBytes += frameRecordSize;<br>
}<br>
#undef X265_FREAD<br>
@@ -1681,9 +1685,9 @@<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>
- analysis->frameRecordSize += sizeof(analysis_inter_data) * analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU;<br>
+ analysis->frameRecordSize += sizeof(int32_t) * analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU;<br>
else<br>
- analysis->frameRecordSize += sizeof(analysis_inter_data) * analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2;<br>
+ analysis->frameRecordSize += sizeof(int32_t) * analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2;<br>
<br>
X265_FWRITE(&analysis->frameRecordSize, sizeof(uint32_t), 1, m_analysisFile);<br>
X265_FWRITE(&analysis->poc, sizeof(int), 1, m_analysisFile);<br>
@@ -1699,11 +1703,11 @@<br>
}<br>
else if (analysis->sliceType == X265_TYPE_P)<br>
{<br>
- X265_FWRITE(analysis->interData, sizeof(analysis_inter_data), 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>
}<br>
else<br>
{<br>
- X265_FWRITE(analysis->interData, sizeof(analysis_inter_data), 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>
}<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></div>