[x265] [PATCH] cli: read and write analysis data based on the slicetype
gopu at multicorewareinc.com
gopu at multicorewareinc.com
Thu Nov 13 09:58:11 CET 2014
# HG changeset patch
# User Gopu Govindaswamy <gopu at multicorewareinc.com>
# Date 1415869080 -19800
# Thu Nov 13 14:28:00 2014 +0530
# Node ID cdf691da4fddcf5fc369d3d322b32462b9249b99
# Parent 0693e0c041fbf0079f97ce35c50029fe130985b6
cli: read and write analysis data based on the slicetype
diff -r 0693e0c041fb -r cdf691da4fdd source/x265.cpp
--- a/source/x265.cpp Thu Nov 13 13:06:52 2014 +0530
+++ b/source/x265.cpp Thu Nov 13 14:28:00 2014 +0530
@@ -885,6 +885,8 @@
int poc, width, height, sliceType;
uint32_t numPart, numCU;
+ uint64_t seekTo = pic->poc * this->analysisRecordSize + this->analysisHeaderSize;
+ fseeko(this->analysisFile, seekTo, SEEK_SET);
FREAD(&width, sizeof(int), 1, this->analysisFile);
FREAD(&height, sizeof(int), 1, this->analysisFile);
FREAD(&poc, sizeof(int), 1, this->analysisFile);
@@ -906,13 +908,17 @@
return;
}
- FREAD(pic->analysisData.intraData->depth,
- sizeof(uint8_t), pic->analysisData.numPartitions * pic->analysisData.numCUsInFrame, this->analysisFile);
- FREAD(pic->analysisData.intraData->modes,
- sizeof(uint8_t), pic->analysisData.numPartitions * pic->analysisData.numCUsInFrame, this->analysisFile);
- FREAD(pic->analysisData.intraData->partSizes,
- sizeof(char), pic->analysisData.numPartitions * pic->analysisData.numCUsInFrame, this->analysisFile);
- FREAD(pic->analysisData.interData, sizeof(x265_inter_data), pic->analysisData.numCUsInFrame * (X265_MAX_PRED_MODE_PER_CU), this->analysisFile);
+ if (sliceType == X265_TYPE_I || sliceType == X265_TYPE_IDR)
+ {
+ FREAD(pic->analysisData.intraData->depth,
+ sizeof(uint8_t), pic->analysisData.numPartitions * pic->analysisData.numCUsInFrame, this->analysisFile);
+ FREAD(pic->analysisData.intraData->modes,
+ sizeof(uint8_t), pic->analysisData.numPartitions * pic->analysisData.numCUsInFrame, this->analysisFile);
+ FREAD(pic->analysisData.intraData->partSizes,
+ sizeof(char), pic->analysisData.numPartitions * pic->analysisData.numCUsInFrame, this->analysisFile);
+ }
+ else
+ FREAD(pic->analysisData.interData, sizeof(x265_inter_data), pic->analysisData.numCUsInFrame * (X265_MAX_PRED_MODE_PER_CU), this->analysisFile);
}
void CLIOptions::writeAnalysisFile(x265_picture* pic, x265_param *p)
@@ -934,14 +940,17 @@
FWRITE(&pic->sliceType, sizeof(int), 1, this->analysisFile);
FWRITE(&pic->analysisData.numCUsInFrame, sizeof(int), 1, this->analysisFile);
FWRITE(&pic->analysisData.numPartitions, sizeof(int), 1, this->analysisFile);
-
- FWRITE(pic->analysisData.intraData->depth,
- sizeof(uint8_t), pic->analysisData.numPartitions * pic->analysisData.numCUsInFrame, this->analysisFile);
- FWRITE(pic->analysisData.intraData->modes,
- sizeof(uint8_t), pic->analysisData.numPartitions * pic->analysisData.numCUsInFrame, this->analysisFile);
- FWRITE(pic->analysisData.intraData->partSizes,
- sizeof(char), pic->analysisData.numPartitions * pic->analysisData.numCUsInFrame, this->analysisFile);
- FWRITE(pic->analysisData.interData, sizeof(x265_inter_data), pic->analysisData.numCUsInFrame * X265_MAX_PRED_MODE_PER_CU, this->analysisFile);
+ if (pic->sliceType == X265_TYPE_I || pic->sliceType == X265_TYPE_IDR)
+ {
+ FWRITE(pic->analysisData.intraData->depth,
+ sizeof(uint8_t), pic->analysisData.numPartitions * pic->analysisData.numCUsInFrame, this->analysisFile);
+ FWRITE(pic->analysisData.intraData->modes,
+ sizeof(uint8_t), pic->analysisData.numPartitions * pic->analysisData.numCUsInFrame, this->analysisFile);
+ FWRITE(pic->analysisData.intraData->partSizes,
+ sizeof(char), pic->analysisData.numPartitions * pic->analysisData.numCUsInFrame, this->analysisFile);
+ }
+ else
+ FWRITE(pic->analysisData.interData, sizeof(x265_inter_data), pic->analysisData.numCUsInFrame * X265_MAX_PRED_MODE_PER_CU, this->analysisFile);
}
bool CLIOptions::parseQPFile(x265_picture &pic_org)
@@ -1039,6 +1048,13 @@
if (param->analysisMode)
{
+ uint32_t numCU = pic_in->analysisData.numCUsInFrame;
+ uint32_t numPart = pic_in->analysisData.numPartitions;
+
+ size_t intraRecordSize = (sizeof(int) * 4 + sizeof(uint32_t) * 2) + sizeof(uint8_t) * 2 * numPart * numCU + sizeof(char) * numPart * numCU;
+ size_t interRecordSize = ((sizeof(int) * 4 + sizeof(uint32_t) * 2) + sizeof(x265_inter_data) * numCU * X265_MAX_PRED_MODE_PER_CU);
+ cliopt.analysisRecordSize = (interRecordSize > intraRecordSize) ? interRecordSize : intraRecordSize;
+
if (param->analysisMode == X265_ANALYSIS_SAVE)
{
char *p = x265_param2string(param);
@@ -1047,14 +1063,7 @@
x265_log(NULL, X265_LOG_ERROR, "analysis: buffer allocation failure, aborting");
goto fail;
}
- uint32_t numCU = pic_in->analysisData.numCUsInFrame;
- uint32_t numPart = pic_in->analysisData.numPartitions;
-
- cliopt.analysisRecordSize = ((sizeof(int) * 4 + sizeof(uint32_t) * 2) + sizeof(x265_inter_data) * numCU * X265_MAX_PRED_MODE_PER_CU +
- sizeof(uint8_t) * 2 * numPart * numCU + sizeof(char) * numPart * numCU);
-
fprintf(cliopt.analysisFile, "#options: %s\n", p);
- cliopt.analysisHeaderSize = ftell(cliopt.analysisFile);
X265_FREE(p);
}
else
@@ -1062,6 +1071,7 @@
if (!cliopt.validateFanout(param))
goto fail;
}
+ cliopt.analysisHeaderSize = ftell(cliopt.analysisFile);
}
if (cliopt.bDither)
More information about the x265-devel
mailing list