[x265] [PATCH] analysis: Dump/reuse scenecut and satdCost of lowres in analysis save and load
sagar at multicorewareinc.com
sagar at multicorewareinc.com
Mon Nov 30 06:56:06 CET 2015
# HG changeset patch
# User Sagar Kotecha<sagar at multicorewareinc.com>
# Date 1448862818 -19800
# Mon Nov 30 11:23:38 2015 +0530
# Node ID 52746770cc6d8cf48200eda65184ef2fc7468d0b
# Parent 687f397dcd65fba080d46b4fd502a8425589cf19
analysis: Dump/reuse scenecut and satdCost of lowres in analysis save and load
Fixes output mismatch for ANALYSIS_SAVE/LOAD
diff -r 687f397dcd65 -r 52746770cc6d source/common/lowres.cpp
--- a/source/common/lowres.cpp Fri Nov 06 12:33:51 2015 +0530
+++ b/source/common/lowres.cpp Mon Nov 30 11:23:38 2015 +0530
@@ -128,12 +128,10 @@
void Lowres::init(PicYuv *origPic, int poc)
{
bLastMiniGopBFrame = false;
- bScenecut = false; // could be a scene-cut, until ruled out by flash detection
bKeyframe = false; // Not a keyframe unless identified by lookahead
frameNum = poc;
leadingBframes = 0;
indB = 0;
- satdCost = (int64_t)-1;
memset(costEst, -1, sizeof(costEst));
memset(weightedCostDelta, 0, sizeof(weightedCostDelta));
diff -r 687f397dcd65 -r 52746770cc6d source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Fri Nov 06 12:33:51 2015 +0530
+++ b/source/encoder/encoder.cpp Mon Nov 30 11:23:38 2015 +0530
@@ -569,6 +569,10 @@
else
{
inFrame = m_dpb->m_freeList.popBack();
+ /* Set lowres scencut and satdCost here to aovid overwriting ANALYSIS_READ
+ decision by lowres init*/
+ inFrame->m_lowres.bScenecut = false;
+ inFrame->m_lowres.satdCost = (int64_t)-1;
inFrame->m_lowresInit = false;
}
@@ -617,11 +621,15 @@
readAnalysisFile(&inputPic->analysisData, inFrame->m_poc);
inFrame->m_analysisData.poc = inFrame->m_poc;
inFrame->m_analysisData.sliceType = inputPic->analysisData.sliceType;
+ inFrame->m_analysisData.bScenecut = inputPic->analysisData.bScenecut;
+ inFrame->m_analysisData.satdCost = inputPic->analysisData.satdCost;
inFrame->m_analysisData.numCUsInFrame = inputPic->analysisData.numCUsInFrame;
inFrame->m_analysisData.numPartitions = inputPic->analysisData.numPartitions;
inFrame->m_analysisData.interData = inputPic->analysisData.interData;
inFrame->m_analysisData.intraData = inputPic->analysisData.intraData;
sliceType = inputPic->analysisData.sliceType;
+ inFrame->m_lowres.bScenecut = inFrame->m_analysisData.bScenecut;
+ inFrame->m_lowres.satdCost = inFrame->m_analysisData.satdCost;
}
m_lookahead->addPicture(*inFrame, sliceType);
@@ -694,6 +702,8 @@
{
pic_out->analysisData.poc = pic_out->poc;
pic_out->analysisData.sliceType = pic_out->sliceType;
+ pic_out->analysisData.bScenecut = outFrame->m_lowres.bScenecut;
+ pic_out->analysisData.satdCost = outFrame->m_lowres.satdCost;
pic_out->analysisData.numCUsInFrame = outFrame->m_analysisData.numCUsInFrame;
pic_out->analysisData.numPartitions = outFrame->m_analysisData.numPartitions;
pic_out->analysisData.interData = outFrame->m_analysisData.interData;
@@ -1904,6 +1914,8 @@
analysis->poc = poc;
analysis->frameRecordSize = frameRecordSize;
X265_FREAD(&analysis->sliceType, sizeof(int), 1, m_analysisFile);
+ X265_FREAD(&analysis->bScenecut, sizeof(bool), 1, m_analysisFile);
+ X265_FREAD(&analysis->satdCost, sizeof(int64_t), 1, m_analysisFile);
X265_FREAD(&analysis->numCUsInFrame, sizeof(int), 1, m_analysisFile);
X265_FREAD(&analysis->numPartitions, sizeof(int), 1, m_analysisFile);
@@ -1955,7 +1967,7 @@
/* calculate frameRecordSize */
analysis->frameRecordSize = sizeof(analysis->frameRecordSize) + sizeof(analysis->poc) + sizeof(analysis->sliceType) +
- sizeof(analysis->numCUsInFrame) + sizeof(analysis->numPartitions);
+ sizeof(analysis->numCUsInFrame) + sizeof(analysis->numPartitions) + sizeof(analysis->bScenecut) + sizeof(analysis->satdCost);
if (analysis->sliceType == X265_TYPE_IDR || analysis->sliceType == X265_TYPE_I)
analysis->frameRecordSize += sizeof(uint8_t) * analysis->numCUsInFrame * analysis->numPartitions * 4;
else if (analysis->sliceType == X265_TYPE_P)
@@ -1975,6 +1987,8 @@
X265_FWRITE(&analysis->frameRecordSize, sizeof(uint32_t), 1, m_analysisFile);
X265_FWRITE(&analysis->poc, sizeof(int), 1, m_analysisFile);
X265_FWRITE(&analysis->sliceType, sizeof(int), 1, m_analysisFile);
+ X265_FWRITE(&analysis->bScenecut, sizeof(bool), 1, m_analysisFile);
+ X265_FWRITE(&analysis->satdCost, sizeof(int64_t), 1, m_analysisFile);
X265_FWRITE(&analysis->numCUsInFrame, sizeof(int), 1, m_analysisFile);
X265_FWRITE(&analysis->numPartitions, sizeof(int), 1, m_analysisFile);
diff -r 687f397dcd65 -r 52746770cc6d source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp Fri Nov 06 12:33:51 2015 +0530
+++ b/source/encoder/slicetype.cpp Mon Nov 30 11:23:38 2015 +0530
@@ -765,10 +765,13 @@
if (m_param->rc.cuTree && !m_param->rc.bStatRead)
/* update row satds based on cutree offsets */
curFrame->m_lowres.satdCost = frameCostRecalculate(frames, p0, p1, b);
- else if (m_param->rc.aqMode)
- curFrame->m_lowres.satdCost = curFrame->m_lowres.costEstAq[b - p0][p1 - b];
- else
- curFrame->m_lowres.satdCost = curFrame->m_lowres.costEst[b - p0][p1 - b];
+ else if (m_param->analysisMode != X265_ANALYSIS_LOAD)
+ {
+ if (m_param->rc.aqMode)
+ curFrame->m_lowres.satdCost = curFrame->m_lowres.costEstAq[b - p0][p1 - b];
+ else
+ curFrame->m_lowres.satdCost = curFrame->m_lowres.costEst[b - p0][p1 - b];
+ }
if (m_param->rc.vbvBufferSize && m_param->rc.vbvMaxBitrate)
{
diff -r 687f397dcd65 -r 52746770cc6d source/x265.h
--- a/source/x265.h Fri Nov 06 12:33:51 2015 +0530
+++ b/source/x265.h Mon Nov 30 11:23:38 2015 +0530
@@ -92,13 +92,15 @@
/* Stores all analysis data for a single frame */
typedef struct x265_analysis_data
{
- void* interData;
- void* intraData;
+ int64_t satdCost;
uint32_t frameRecordSize;
uint32_t poc;
uint32_t sliceType;
uint32_t numCUsInFrame;
uint32_t numPartitions;
+ void* interData;
+ void* intraData;
+ bool bScenecut;
} x265_analysis_data;
/* cu statistics */
More information about the x265-devel
mailing list