<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 21, 2017 at 12:21 PM, <span dir="ltr"><<a href="mailto:kavitha@multicorewareinc.com" target="_blank">kavitha@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""># HG changeset patch<br>
# User Kavitha Sampath <<a href="mailto:kavitha@multicorewareinc.com">kavitha@multicorewareinc.com</a>><br>
# Date 1497342640 -19800<br>
# Tue Jun 13 14:00:40 2017 +0530<br>
</span># Node ID 40dbeef1d8b59452ac0898621a75f0<wbr>2a576b0c30<br>
# Parent a015be4021f3de8ee265cded1eb7c4<wbr>76dedf3f36<br>
<span class="">add param option to specify file read/write of analysis data<br></span></blockquote><div><br></div><div>Pushed into default branch</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
<br>
</span>diff -r a015be4021f3 -r 40dbeef1d8b5 source/CMakeLists.txt<br>
--- a/source/CMakeLists.txt Tue May 30 14:49:37 2017 +0530<br>
+++ b/source/CMakeLists.txt Tue Jun 13 14:00:40 2017 +0530<br>
@@ -29,7 +29,7 @@<br>
option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)<br>
mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)<br>
# X265_BUILD must be incremented each time the public API is changed<br>
-set(X265_BUILD 126)<br>
+set(X265_BUILD 127)<br>
configure_file("${PROJECT_<wbr>SOURCE_DIR}/<a href="http://x265.def.in" rel="noreferrer" target="_blank">x265.def.in</a>"<br>
"${PROJECT_BINARY_DIR}/x265.<wbr>def")<br>
configure_file("${PROJECT_<wbr>SOURCE_DIR}/<a href="http://x265_config.h.in" rel="noreferrer" target="_blank">x265_config.h.in</a>"<br>
diff -r a015be4021f3 -r 40dbeef1d8b5 source/common/param.cpp<br>
<span class="">--- a/source/common/param.cpp Tue May 30 14:49:37 2017 +0530<br>
+++ b/source/common/param.cpp Tue Jun 13 14:00:40 2017 +0530<br>
@@ -282,6 +282,7 @@<br>
param->intraRefine = 0;<br>
param->interRefine = 0;<br>
param->mvRefine = 0;<br>
+ param->bUseAnalysisFile = 1;<br>
}<br>
<br>
int x265_param_default_preset(<wbr>x265_param* param, const char* preset, const char* tune)<br>
</span>diff -r a015be4021f3 -r 40dbeef1d8b5 source/encoder/encoder.cpp<br>
<div><div class="h5">--- a/source/encoder/encoder.cpp Tue May 30 14:49:37 2017 +0530<br>
+++ b/source/encoder/encoder.cpp Tue Jun 13 14:00:40 2017 +0530<br>
@@ -598,6 +598,8 @@<br>
<br>
if (m_exportedPic)<br>
{<br>
+ if (!m_param->bUseAnalysisFile && m_param->analysisMode == X265_ANALYSIS_SAVE)<br>
+ freeAnalysis(&m_exportedPic-><wbr>m_analysisData);<br>
ATOMIC_DEC(&m_exportedPic->m_<wbr>countRefEncoders);<br>
m_exportedPic = NULL;<br>
m_dpb->recycleUnreferenced();<br>
@@ -766,19 +768,9 @@<br>
/* Load analysis data before lookahead->addPicture, since sliceType has been decided */<br>
if (m_param->analysisMode == X265_ANALYSIS_LOAD)<br>
{<br>
- x265_picture* inputPic = const_cast<x265_picture*>(pic_<wbr>in);<br>
/* readAnalysisFile reads analysis data for the frame and allocates memory based on slicetype */<br>
- readAnalysisFile(&inputPic-><wbr>analysisData, inFrame->m_poc);<br>
- inFrame->m_analysisData.poc = inFrame->m_poc;<br>
- inFrame->m_analysisData.<wbr>sliceType = inputPic->analysisData.<wbr>sliceType;<br>
- inFrame->m_analysisData.<wbr>bScenecut = inputPic->analysisData.<wbr>bScenecut;<br>
- inFrame->m_analysisData.<wbr>satdCost = inputPic->analysisData.<wbr>satdCost;<br>
- inFrame->m_analysisData.<wbr>numCUsInFrame = inputPic->analysisData.<wbr>numCUsInFrame;<br>
- inFrame->m_analysisData.<wbr>numPartitions = inputPic->analysisData.<wbr>numPartitions;<br>
- inFrame->m_analysisData.wt = inputPic->analysisData.wt;<br>
- inFrame->m_analysisData.<wbr>interData = inputPic->analysisData.<wbr>interData;<br>
- inFrame->m_analysisData.<wbr>intraData = inputPic->analysisData.<wbr>intraData;<br>
- sliceType = inputPic->analysisData.<wbr>sliceType;<br>
+ readAnalysisFile(&inFrame->m_<wbr>analysisData, inFrame->m_poc, pic_in);<br>
+ sliceType = inFrame->m_analysisData.<wbr>sliceType;<br>
inFrame->m_lowres.bScenecut = !!inFrame->m_analysisData.<wbr>bScenecut;<br>
inFrame->m_lowres.satdCost = inFrame->m_analysisData.<wbr>satdCost;<br>
}<br>
@@ -879,7 +871,8 @@<br>
pic_out->analysisData.<wbr>interData = outFrame->m_analysisData.<wbr>interData;<br>
pic_out->analysisData.<wbr>intraData = outFrame->m_analysisData.<wbr>intraData;<br>
writeAnalysisFile(&pic_out-><wbr>analysisData, *outFrame->m_encData);<br>
- freeAnalysis(&pic_out-><wbr>analysisData);<br>
+ if (m_param->bUseAnalysisFile)<br>
+ freeAnalysis(&pic_out-><wbr>analysisData);<br>
}<br>
}<br>
if (m_param->rc.bStatWrite && (m_param-><wbr>analysisMultiPassRefine || m_param-><wbr>analysisMultiPassDistortion))<br>
@@ -2838,11 +2831,15 @@<br>
}<br>
}<br>
<br>
-void Encoder::readAnalysisFile(<wbr>x265_analysis_data* analysis, int curPoc)<br>
+void Encoder::readAnalysisFile(<wbr>x265_analysis_data* analysis, int curPoc, const x265_picture* picIn)<br>
{<br>
<br>
-#define X265_FREAD(val, size, readSize, fileOffset)\<br>
- if (fread(val, size, readSize, fileOffset) != readSize)\<br>
+#define X265_FREAD(val, size, readSize, fileOffset, src)\<br>
+ if (!m_param->bUseAnalysisFile)\<br>
+ {\<br>
+ memcpy(val, src, (size * readSize));\<br>
+ }\<br>
+ else if (fread(val, size, readSize, fileOffset) != readSize)\<br>
{\<br>
x265_log(NULL, X265_LOG_ERROR, "Error reading analysis data\n");\<br>
freeAnalysis(analysis);\<br>
@@ -2855,38 +2852,44 @@<br>
uint32_t depthBytes = 0;<br>
fseeko(m_analysisFile, totalConsumedBytes, 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>
+<br>
int poc; uint32_t frameRecordSize;<br>
- X265_FREAD(&frameRecordSize, sizeof(uint32_t), 1, m_analysisFile);<br>
- X265_FREAD(&depthBytes, sizeof(uint32_t), 1, m_analysisFile);<br>
- X265_FREAD(&poc, sizeof(int), 1, m_analysisFile);<br>
-<br>
- uint64_t currentOffset = totalConsumedBytes;<br>
-<br>
- /* Seeking to the right frame Record */<br>
- while (poc != curPoc && !feof(m_analysisFile))<br>
+ X265_FREAD(&frameRecordSize, sizeof(uint32_t), 1, m_analysisFile, &(picData->frameRecordSize));<br>
+ X265_FREAD(&depthBytes, sizeof(uint32_t), 1, m_analysisFile, &(picData->depthBytes));<br>
+ X265_FREAD(&poc, sizeof(int), 1, m_analysisFile, &(picData->poc));<br>
+<br>
+ if (m_param->bUseAnalysisFile)<br>
{<br>
- currentOffset += frameRecordSize;<br>
- fseeko(m_analysisFile, currentOffset, SEEK_SET);<br>
- X265_FREAD(&frameRecordSize, sizeof(uint32_t), 1, m_analysisFile);<br>
- X265_FREAD(&depthBytes, sizeof(uint32_t), 1, m_analysisFile);<br>
- X265_FREAD(&poc, sizeof(int), 1, m_analysisFile);<br>
- }<br>
-<br>
- if (poc != curPoc || feof(m_analysisFile))<br>
- {<br>
- x265_log(NULL, X265_LOG_WARNING, "Error reading analysis data: Cannot find POC %d\n", curPoc);<br>
- freeAnalysis(analysis);<br>
- return;<br>
+ uint64_t currentOffset = totalConsumedBytes;<br>
+<br>
+ /* Seeking to the right frame Record */<br>
+ while (poc != curPoc && !feof(m_analysisFile))<br>
+ {<br>
+ currentOffset += frameRecordSize;<br>
+ fseeko(m_analysisFile, currentOffset, SEEK_SET);<br>
+ X265_FREAD(&frameRecordSize, sizeof(uint32_t), 1, m_analysisFile, &(picData->frameRecordSize));<br>
+ X265_FREAD(&depthBytes, sizeof(uint32_t), 1, m_analysisFile, &(picData->depthBytes));<br>
+ X265_FREAD(&poc, sizeof(int), 1, m_analysisFile, &(picData->poc));<br>
+ }<br>
+ if (poc != curPoc || feof(m_analysisFile))<br>
+ {<br>
+ x265_log(NULL, X265_LOG_WARNING, "Error reading analysis data: Cannot find POC %d\n", curPoc);<br>
+ freeAnalysis(analysis);<br>
+ return;<br>
+ }<br>
}<br>
<br>
/* Now arrived at the right frame, read the record */<br>
analysis->poc = poc;<br>
analysis->frameRecordSize = frameRecordSize;<br>
- X265_FREAD(&analysis-><wbr>sliceType, sizeof(int), 1, m_analysisFile);<br>
- X265_FREAD(&analysis-><wbr>bScenecut, sizeof(int), 1, m_analysisFile);<br>
- X265_FREAD(&analysis-><wbr>satdCost, sizeof(int64_t), 1, m_analysisFile);<br>
- X265_FREAD(&analysis-><wbr>numCUsInFrame, sizeof(int), 1, m_analysisFile);<br>
- X265_FREAD(&analysis-><wbr>numPartitions, sizeof(int), 1, m_analysisFile);<br>
+ X265_FREAD(&analysis-><wbr>sliceType, sizeof(int), 1, m_analysisFile, &(picData->sliceType));<br>
+ X265_FREAD(&analysis-><wbr>bScenecut, sizeof(int), 1, m_analysisFile, &(picData->bScenecut));<br>
+ X265_FREAD(&analysis-><wbr>satdCost, sizeof(int64_t), 1, m_analysisFile, &(picData->satdCost));<br>
+ X265_FREAD(&analysis-><wbr>numCUsInFrame, sizeof(int), 1, m_analysisFile, &(picData->numCUsInFrame));<br>
+ X265_FREAD(&analysis-><wbr>numPartitions, sizeof(int), 1, m_analysisFile, &(picData->numPartitions));<br>
int scaledNumPartition = analysis->numPartitions;<br>
int factor = 1 << m_param->scaleFactor;<br>
<br>
@@ -2904,12 +2907,14 @@<br>
uint8_t *tempBuf = NULL, *depthBuf = NULL, *modeBuf = NULL, *partSizes = NULL;<br>
<br>
tempBuf = X265_MALLOC(uint8_t, depthBytes * 3);<br>
- X265_FREAD(tempBuf, sizeof(uint8_t), depthBytes * 3, m_analysisFile);<br>
-<br>
depthBuf = tempBuf;<br>
modeBuf = tempBuf + depthBytes;<br>
partSizes = tempBuf + 2 * depthBytes;<br>
<br>
+ X265_FREAD(depthBuf, sizeof(uint8_t), depthBytes, m_analysisFile, intraPic->depth);<br>
+ X265_FREAD(modeBuf, sizeof(uint8_t), depthBytes, m_analysisFile, intraPic->chromaModes);<br>
+ X265_FREAD(partSizes, sizeof(uint8_t), depthBytes, m_analysisFile, intraPic->partSizes);<br>
+<br>
size_t count = 0;<br>
for (uint32_t d = 0; d < depthBytes; d++)<br>
{<br>
@@ -2929,12 +2934,12 @@<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_analysisFile);<br>
+ X265_FREAD(((analysis_intra_<wbr>data *)analysis->intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFile, 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_analysisFile);<br>
+ X265_FREAD(tempLumaBuf, sizeof(uint8_t), analysis->numCUsInFrame * scaledNumPartition, m_analysisFile, 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>
X265_FREE(tempLumaBuf);<br>
@@ -2947,7 +2952,7 @@<br>
{<br>
uint32_t numDir = analysis->sliceType == X265_TYPE_P ? 1 : 2;<br>
uint32_t numPlanes = m_param->internalCsp == X265_CSP_I400 ? 1 : 3;<br>
- X265_FREAD((WeightParam*)<wbr>analysis->wt, sizeof(WeightParam), numPlanes * numDir, m_analysisFile);<br>
+ X265_FREAD((WeightParam*)<wbr>analysis->wt, sizeof(WeightParam), numPlanes * numDir, m_analysisFile, (picIn->analysisData.wt));<br>
if (m_param->analysisRefineLevel < 2)<br>
return;<br>
<br>
@@ -2966,26 +2971,36 @@<br>
}<br>
<br>
tempBuf = X265_MALLOC(uint8_t, depthBytes * numBuf);<br>
- X265_FREAD(tempBuf, sizeof(uint8_t), depthBytes * numBuf, m_analysisFile);<br>
-<br>
depthBuf = tempBuf;<br>
modeBuf = tempBuf + depthBytes;<br>
+<br>
+ X265_FREAD(depthBuf, sizeof(uint8_t), depthBytes, m_analysisFile, interPic->depth);<br>
+ X265_FREAD(modeBuf, sizeof(uint8_t), depthBytes, m_analysisFile, interPic->modes);<br>
+<br>
if (m_param->analysisRefineLevel > 4)<br>
{<br>
partSize = modeBuf + depthBytes;<br>
mergeFlag = partSize + depthBytes;<br>
+ X265_FREAD(partSize, sizeof(uint8_t), depthBytes, m_analysisFile, interPic->partSize);<br>
+ X265_FREAD(mergeFlag, sizeof(uint8_t), depthBytes, m_analysisFile, interPic->mergeFlag);<br>
+<br>
if (m_param->analysisRefineLevel == 10)<br>
{<br>
interDir = mergeFlag + depthBytes;<br>
- if (bIntraInInter) chromaDir = interDir + depthBytes;<br>
+ X265_FREAD(interDir, sizeof(uint8_t), depthBytes, m_analysisFile, interPic->interDir);<br>
+ if (bIntraInInter)<br>
+ {<br>
+ chromaDir = interDir + depthBytes;<br>
+ X265_FREAD(chromaDir, sizeof(uint8_t), depthBytes, m_analysisFile, intraPic->chromaModes);<br>
+ }<br>
for (uint32_t i = 0; i < numDir; i++)<br>
{<br>
- mvpIdx[i] = X265_MALLOC(uint8_t, depthBytes * 3);<br>
- X265_FREAD(mvpIdx[i], sizeof(uint8_t), depthBytes, m_analysisFile);<br>
+ mvpIdx[i] = X265_MALLOC(uint8_t, depthBytes);<br>
refIdx[i] = X265_MALLOC(int8_t, depthBytes);<br>
- X265_FREAD(refIdx[i], sizeof(int8_t), depthBytes, m_analysisFile);<br>
mv[i] = X265_MALLOC(MV, depthBytes);<br>
- X265_FREAD(mv[i], sizeof(MV), depthBytes, m_analysisFile);<br>
+ X265_FREAD(mvpIdx[i], sizeof(uint8_t), depthBytes, m_analysisFile, interPic->mvpIdx[i]);<br>
+ X265_FREAD(refIdx[i], sizeof(int8_t), depthBytes, m_analysisFile, interPic->refIdx[i]);<br>
+ X265_FREAD(mv[i], sizeof(MV), depthBytes, m_analysisFile, interPic->mv[i]);<br>
}<br>
}<br>
}<br>
@@ -3044,12 +3059,12 @@<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_analysisFile);<br>
+ X265_FREAD(((analysis_intra_<wbr>data *)analysis->intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFile, 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_analysisFile);<br>
+ X265_FREAD(tempLumaBuf, sizeof(uint8_t), analysis->numCUsInFrame * scaledNumPartition, m_analysisFile, 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>
X265_FREE(tempLumaBuf);<br>
@@ -3057,7 +3072,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_analysisFile);<br>
+ X265_FREAD(((analysis_inter_<wbr>data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFile, interPic->ref);<br>
<br>
consumedBytes += frameRecordSize;<br>
if (numDir == 1)<br>
@@ -3326,7 +3341,12 @@<br>
else<br>
analysis->frameRecordSize += sizeof(int32_t)* analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir;<br>
}<br>
+ analysis->depthBytes = depthBytes;<br>
}<br>
+<br>
+ if (!m_param->bUseAnalysisFile)<br>
+ return;<br>
+<br>
X265_FWRITE(&analysis-><wbr>frameRecordSize, sizeof(uint32_t), 1, m_analysisFile);<br>
X265_FWRITE(&depthBytes, sizeof(uint32_t), 1, m_analysisFile);<br>
X265_FWRITE(&analysis->poc, sizeof(int), 1, m_analysisFile);<br>
</div></div>diff -r a015be4021f3 -r 40dbeef1d8b5 source/encoder/encoder.h<br>
<span class="">--- a/source/encoder/encoder.h Tue May 30 14:49:37 2017 +0530<br>
+++ b/source/encoder/encoder.h Tue Jun 13 14:00:40 2017 +0530<br>
@@ -224,7 +224,7 @@<br>
<br>
void freeAnalysis2Pass(x265_<wbr>analysis_2Pass* analysis, int sliceType);<br>
<br>
- void readAnalysisFile(x265_<wbr>analysis_data* analysis, int poc);<br>
+ void readAnalysisFile(x265_<wbr>analysis_data* analysis, int poc, const x265_picture* picIn);<br>
<br>
void writeAnalysisFile(x265_<wbr>analysis_data* pic, FrameData &curEncData);<br>
void readAnalysis2PassFile(x265_<wbr>analysis_2Pass* analysis2Pass, int poc, int sliceType);<br>
</span>diff -r a015be4021f3 -r 40dbeef1d8b5 source/x265.h<br>
<span class="">--- a/source/x265.h Tue May 30 14:49:37 2017 +0530<br>
+++ b/source/x265.h Tue Jun 13 14:00:40 2017 +0530<br>
@@ -98,6 +98,7 @@<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>
@@ -1471,6 +1472,9 @@<br>
/* Number of 4x4 units in maximum CU size */<br>
uint32_t num4x4Partitions;<br>
<br>
+ /* Specify if analysis mode uses file for data reuse */<br>
+ int bUseAnalysisFile;<br>
+<br>
} x265_param;<br>
<br>
/* x265_param_alloc:<br>
</span>______________________________<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>
</blockquote></div><br></div></div>