[x265] [PATCH] analysis: modified inter analysis structure to reduce the analysis file size
gopu at multicorewareinc.com
gopu at multicorewareinc.com
Tue Dec 23 12:27:23 CET 2014
# HG changeset patch
# User Gopu Govindaswamy <gopu at multicorewareinc.com>
# Date 1419326367 -19800
# Tue Dec 23 14:49:27 2014 +0530
# Node ID 2e70b3bd72c1fc7917e9bef704def2ebd941e08f
# Parent 9fdab427a1918939293539f07b49ce77c5104912
analysis: modified inter analysis structure to reduce the analysis file size
diff -r 9fdab427a191 -r 2e70b3bd72c1 source/common/common.h
--- a/source/common/common.h Tue Dec 23 12:17:08 2014 +0530
+++ b/source/common/common.h Tue Dec 23 14:49:27 2014 +0530
@@ -362,7 +362,7 @@
/* Stores inter (motion estimation) analysis data for a single frame */
struct analysis_inter_data
{
- int ref;
+ int32_t* ref;
};
/* Stores intra analysis data for a single frame. This struct needs better packing */
diff -r 9fdab427a191 -r 2e70b3bd72c1 source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp Tue Dec 23 12:17:08 2014 +0530
+++ b/source/encoder/analysis.cpp Tue Dec 23 14:49:27 2014 +0530
@@ -133,9 +133,14 @@
uint32_t numPartition = ctu.m_numPartitions;
if (m_param->analysisMode)
{
- m_reuseIntraDataCTU = (analysis_intra_data *)m_frame->m_analysisData.intraData;
- int numPredDir = m_slice->isInterP() ? 1 : 2;
- m_reuseInterDataCTU = (analysis_inter_data *)m_frame->m_analysisData.interData + ctu.m_cuAddr * X265_MAX_PRED_MODE_PER_CTU * numPredDir;
+ if (m_slice->m_sliceType == I_SLICE)
+ m_reuseIntraDataCTU = (analysis_intra_data *)m_frame->m_analysisData.intraData;
+ else
+ {
+ int numPredDir = m_slice->isInterP() ? 1 : 2;
+ m_reuseInterDataCTU = (analysis_inter_data *)m_frame->m_analysisData.interData;
+ sharedRef = &m_reuseInterDataCTU->ref[ctu.m_cuAddr * X265_MAX_PRED_MODE_PER_CTU * numPredDir];
+ }
}
if (m_slice->m_sliceType == I_SLICE)
@@ -1437,8 +1442,8 @@
MotionData* bestME = interMode.bestME[part];
for (int32_t i = 0; i < numPredDir; i++)
{
- bestME[i].ref = m_reuseInterDataCTU->ref;
- m_reuseInterDataCTU++;
+ bestME[i].ref = *sharedRef;
+ sharedRef++;
}
}
}
@@ -1465,8 +1470,8 @@
MotionData* bestME = interMode.bestME[puIdx];
for (int32_t i = 0; i < numPredDir; i++)
{
- m_reuseInterDataCTU->ref = bestME[i].ref;
- m_reuseInterDataCTU++;
+ *sharedRef = bestME[i].ref;
+ sharedRef++;
}
}
}
@@ -1492,8 +1497,8 @@
MotionData* bestME = interMode.bestME[puIdx];
for (int32_t i = 0; i < numPredDir; i++)
{
- bestME[i].ref = m_reuseInterDataCTU->ref;
- m_reuseInterDataCTU++;
+ bestME[i].ref = *sharedRef;
+ sharedRef++;
}
}
}
@@ -1509,8 +1514,8 @@
MotionData* bestME = interMode.bestME[puIdx];
for (int32_t i = 0; i < numPredDir; i++)
{
- m_reuseInterDataCTU->ref = bestME[i].ref;
- m_reuseInterDataCTU++;
+ *sharedRef = bestME[i].ref;
+ sharedRef++;
}
}
}
diff -r 9fdab427a191 -r 2e70b3bd72c1 source/encoder/analysis.h
--- a/source/encoder/analysis.h Tue Dec 23 12:17:08 2014 +0530
+++ b/source/encoder/analysis.h Tue Dec 23 14:49:27 2014 +0530
@@ -77,6 +77,7 @@
/* Analysis data for load/save modes, keeps getting incremented as CTU analysis proceeds and data is consumed or read */
analysis_intra_data* m_reuseIntraDataCTU;
analysis_inter_data* m_reuseInterDataCTU;
+ int32_t* sharedRef;
Analysis();
bool create(ThreadLocalData* tld);
void destroy();
diff -r 9fdab427a191 -r 2e70b3bd72c1 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Tue Dec 23 12:17:08 2014 +0530
+++ b/source/encoder/encoder.cpp Tue Dec 23 14:49:27 2014 +0530
@@ -1570,7 +1570,8 @@
else
{
analysis_inter_data *interData = (analysis_inter_data*)analysis->interData;
- CHECKED_MALLOC(interData, analysis_inter_data, analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2);
+ CHECKED_MALLOC_ZERO(interData, analysis_inter_data, 1);
+ CHECKED_MALLOC(interData->ref, int32_t, analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2);
analysis->interData = interData;
}
return;
@@ -1590,7 +1591,10 @@
X265_FREE(analysis->intraData);
}
else
+ {
+ X265_FREE(((analysis_inter_data*)analysis->interData)->ref);
X265_FREE(analysis->interData);
+ }
}
void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc)
@@ -1651,13 +1655,13 @@
}
else if (analysis->sliceType == X265_TYPE_P)
{
- X265_FREAD(analysis->interData, sizeof(analysis_inter_data), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU, m_analysisFile);
+ X265_FREAD(((analysis_inter_data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU, m_analysisFile);
consumedBytes += frameRecordSize;
totalConsumedBytes = consumedBytes;
}
else
{
- X265_FREAD(analysis->interData, sizeof(analysis_inter_data), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2, m_analysisFile);
+ X265_FREAD(((analysis_inter_data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2, m_analysisFile);
consumedBytes += frameRecordSize;
}
#undef X265_FREAD
@@ -1681,9 +1685,9 @@
if (analysis->sliceType == X265_TYPE_IDR || analysis->sliceType == X265_TYPE_I)
analysis->frameRecordSize += sizeof(uint8_t) * analysis->numCUsInFrame * analysis->numPartitions * 3;
else if (analysis->sliceType == X265_TYPE_P)
- analysis->frameRecordSize += sizeof(analysis_inter_data) * analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU;
+ analysis->frameRecordSize += sizeof(int32_t) * analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU;
else
- analysis->frameRecordSize += sizeof(analysis_inter_data) * analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2;
+ analysis->frameRecordSize += sizeof(int32_t) * analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2;
X265_FWRITE(&analysis->frameRecordSize, sizeof(uint32_t), 1, m_analysisFile);
X265_FWRITE(&analysis->poc, sizeof(int), 1, m_analysisFile);
@@ -1699,11 +1703,11 @@
}
else if (analysis->sliceType == X265_TYPE_P)
{
- X265_FWRITE(analysis->interData, sizeof(analysis_inter_data), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU, m_analysisFile);
+ X265_FWRITE(((analysis_inter_data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU, m_analysisFile);
}
else
{
- X265_FWRITE(analysis->interData, sizeof(analysis_inter_data), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2, m_analysisFile);
+ X265_FWRITE(((analysis_inter_data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2, m_analysisFile);
}
#undef X265_FWRITE
}
More information about the x265-devel
mailing list