[x265] [PATCH 4 of 5] Set all I frames as keyframes, change nalunittype decision accordingly
deepthidevaki at multicorewareinc.com
deepthidevaki at multicorewareinc.com
Fri Sep 6 15:17:36 CEST 2013
# HG changeset patch
# User Deepthi Devaki <deepthidevaki at multicorewareinc.com>
# Date 1378467716 -19800
# Node ID ca65bd3590ccd05f4c87adee53b9b866279470b6
# Parent 491e4a95a6e4e6a94723cf5011fc69398278a102
Set all I frames as keyframes, change nalunittype decision accordingly.
diff -r 491e4a95a6e4 -r ca65bd3590cc source/common/lowres.cpp
--- a/source/common/lowres.cpp Fri Sep 06 15:45:35 2013 +0530
+++ b/source/common/lowres.cpp Fri Sep 06 17:11:56 2013 +0530
@@ -113,6 +113,7 @@
bIntraCalculated = false;
memset(costEst, -1, sizeof(costEst));
sliceType = X265_TYPE_AUTO;
+ keyframe = 0; //Not a keyframe unless identified by lookahead
for (int y = 0; y < bframes + 2; y++)
{
for (int x = 0; x < bframes + 2; x++)
diff -r 491e4a95a6e4 -r ca65bd3590cc source/common/lowres.h
--- a/source/common/lowres.h Fri Sep 06 15:45:35 2013 +0530
+++ b/source/common/lowres.h Fri Sep 06 17:11:56 2013 +0530
@@ -63,6 +63,7 @@
int scenecut; // Set to zero if the frame cannot possibly be part of a real scenecut.
int sliceType; // Slice type decided by lookahead
+ int keyframe;
/* lookahead output data */
int costEst[X265_BFRAME_MAX + 2][X265_BFRAME_MAX + 2];
diff -r 491e4a95a6e4 -r ca65bd3590cc source/encoder/dpb.cpp
--- a/source/encoder/dpb.cpp Fri Sep 06 15:45:35 2013 +0530
+++ b/source/encoder/dpb.cpp Fri Sep 06 17:11:56 2013 +0530
@@ -71,8 +71,8 @@
m_picList.pushFront(pic);
TComSlice* slice = pic->getSlice();
- if (getNalUnitType(pocCurr, m_lastIDR) == NAL_UNIT_CODED_SLICE_IDR_W_RADL ||
- getNalUnitType(pocCurr, m_lastIDR) == NAL_UNIT_CODED_SLICE_IDR_N_LP)
+ if (getNalUnitType(pocCurr, m_lastIDR, pic) == NAL_UNIT_CODED_SLICE_IDR_W_RADL ||
+ getNalUnitType(pocCurr, m_lastIDR, pic) == NAL_UNIT_CODED_SLICE_IDR_N_LP)
{
m_lastIDR = pocCurr;
}
@@ -80,7 +80,7 @@
slice->setReferenced(slice->getSliceType() != B_SLICE);
slice->setTemporalLayerNonReferenceFlag(!slice->isReferenced());
// Set the nal unit type
- slice->setNalUnitType(getNalUnitType(pocCurr, m_lastIDR));
+ slice->setNalUnitType(getNalUnitType(pocCurr, m_lastIDR, pic));
// If the slice is un-referenced, change from _R "referenced" to _N "non-referenced" NAL unit type
if (slice->getTemporalLayerNonReferenceFlag())
@@ -368,13 +368,13 @@
* \returns the nal unit type of the picture
* This function checks the configuration and returns the appropriate nal_unit_type for the picture.
*/
-NalUnitType DPB::getNalUnitType(int curPOC, int lastIDR)
+NalUnitType DPB::getNalUnitType(int curPOC, int lastIDR, TComPic* pic)
{
if (curPOC == 0)
{
return NAL_UNIT_CODED_SLICE_IDR_W_RADL;
}
- if (curPOC % m_cfg->param.keyframeMax == 0)
+ if (pic->m_lowres.keyframe)
{
if (m_cfg->param.decodingRefreshType == 1)
{
diff -r 491e4a95a6e4 -r ca65bd3590cc source/encoder/dpb.h
--- a/source/encoder/dpb.h Fri Sep 06 15:45:35 2013 +0530
+++ b/source/encoder/dpb.h Fri Sep 06 17:11:56 2013 +0530
@@ -71,7 +71,7 @@
void arrangeLongtermPicturesInRPS(TComSlice *, FrameEncoder *frameEncoder);
- NalUnitType getNalUnitType(int curPoc, int lastIdr);
+ NalUnitType getNalUnitType(int curPoc, int lastIdr, TComPic* pic);
};
}
diff -r 491e4a95a6e4 -r ca65bd3590cc source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp Fri Sep 06 15:45:35 2013 +0530
+++ b/source/encoder/slicetype.cpp Fri Sep 06 17:11:56 2013 +0530
@@ -105,6 +105,7 @@
outputQueue.pushBack(pic);
numDecided++;
lastKeyframe = 0;
+ pic->m_lowres.keyframe = 1;
frames[0] = &(pic->m_lowres);
return;
}
@@ -124,8 +125,9 @@
{
pic = inputQueue.popFront();
picsAnalysed[idx++] = pic;
- if ((pic->m_lowres.sliceType == X265_TYPE_I) && !(pic->getPOC() % cfg->param.keyframeMax))
+ if ((pic->m_lowres.sliceType == X265_TYPE_I))
{
+ pic->m_lowres.keyframe = 1;
lastKeyframe = pic->getPOC();
}
}
@@ -148,6 +150,7 @@
TComPic *pic = inputQueue.popFront();
pic->m_lowres.sliceType = X265_TYPE_I;
+ pic->m_lowres.keyframe = 1;
outputQueue.pushBack(pic);
numDecided++;
}
@@ -157,6 +160,7 @@
bool forceIntra = (pic->getPOC() % cfg->param.keyframeMax) == 0;
pic->m_lowres.sliceType = forceIntra ? X265_TYPE_I : X265_TYPE_P;
+ pic->m_lowres.keyframe = forceIntra ? 1 : 0;
outputQueue.pushBack(pic);
numDecided++;
}
@@ -169,10 +173,12 @@
if (forceIntra)
{
picB->m_lowres.sliceType = (picB->getPOC() % cfg->param.keyframeMax) ? X265_TYPE_P : X265_TYPE_I;
+ picB->m_lowres.keyframe = (picB->getPOC() % cfg->param.keyframeMax) ? 0 : 1;
outputQueue.pushBack(picB);
numDecided++;
picP->m_lowres.sliceType = (picP->getPOC() % cfg->param.keyframeMax) ? X265_TYPE_P : X265_TYPE_I;
+ picP->m_lowres.keyframe = (picP->getPOC() % cfg->param.keyframeMax) ? 0 : 1;
outputQueue.pushBack(picP);
numDecided++;
}
More information about the x265-devel
mailing list