[x265] [PATCH] Removed Encoder* as member of DPB and replaced it with x265_param* passed to its methods
dtyx265 at gmail.com
dtyx265 at gmail.com
Fri Mar 7 01:41:57 CET 2014
# HG changeset patch
# User David T Yuen <dtyx265 at gmail.com>
# Date 1394152864 28800
# Node ID b95dc6fea48c58c9330481a7f3de7b48a0a35a0a
# Parent 7209562f4cc8ac53ad075e4f68a635cd739ff8f8
Removed Encoder* as member of DPB and replaced it with x265_param* passed to its methods
Also added int bframes to Lowres since only param->bframes is passed to its methods thus eliminating one of DPB's uses of Encoder*
diff -r 7209562f4cc8 -r b95dc6fea48c source/Lib/TLibCommon/TComPic.cpp
--- a/source/Lib/TLibCommon/TComPic.cpp Thu Mar 06 15:29:23 2014 -0600
+++ b/source/Lib/TLibCommon/TComPic.cpp Thu Mar 06 16:41:04 2014 -0800
@@ -154,7 +154,7 @@
memset(m_qpaAq, 0, m_picSym->getFrameHeightInCU() * sizeof(double));
}
-void TComPic::destroy(int bframes)
+void TComPic::destroy()
{
if (m_picSym)
{
@@ -176,7 +176,7 @@
delete m_reconPicYuv;
m_reconPicYuv = NULL;
}
- m_lowres.destroy(bframes);
+ m_lowres.destroy();
X265_FREE(m_rowDiagQp);
X265_FREE(m_rowDiagQScale);
diff -r 7209562f4cc8 -r b95dc6fea48c source/Lib/TLibCommon/TComPic.h
--- a/source/Lib/TLibCommon/TComPic.h Thu Mar 06 15:29:23 2014 -0600
+++ b/source/Lib/TLibCommon/TComPic.h Thu Mar 06 16:41:04 2014 -0800
@@ -119,7 +119,7 @@
virtual ~TComPic();
bool create(Encoder* cfg);
- virtual void destroy(int bframes);
+ virtual void destroy();
void reInit(Encoder* cfg);
bool getUsedByCurr() { return m_bUsedByCurr; }
diff -r 7209562f4cc8 -r b95dc6fea48c source/common/lowres.cpp
--- a/source/common/lowres.cpp Thu Mar 06 15:29:23 2014 -0600
+++ b/source/common/lowres.cpp Thu Mar 06 16:41:04 2014 -0800
@@ -27,9 +27,10 @@
using namespace x265;
-bool Lowres::create(TComPicYuv *orig, int bframes, bool bAQEnabled)
+bool Lowres::create(TComPicYuv *orig, int _bframes, bool bAQEnabled)
{
isLowres = true;
+ bframes = _bframes;
width = orig->getWidth() / 2;
lines = orig->getHeight() / 2;
lumaStride = width + 2 * orig->getLumaMarginX();
@@ -92,7 +93,7 @@
return false;
}
-void Lowres::destroy(int bframes)
+void Lowres::destroy()
{
for (int i = 0; i < 4; i++)
{
@@ -125,7 +126,7 @@
}
// (re) initialize lowres state
-void Lowres::init(TComPicYuv *orig, int poc, int type, int bframes)
+void Lowres::init(TComPicYuv *orig, int poc, int type)
{
bIntraCalculated = false;
bLastMiniGopBFrame = false;
diff -r 7209562f4cc8 -r b95dc6fea48c source/common/lowres.h
--- a/source/common/lowres.h Thu Mar 06 15:29:23 2014 -0600
+++ b/source/common/lowres.h Thu Mar 06 16:41:04 2014 -0800
@@ -123,6 +123,7 @@
MV* lowresMvs[2][X265_BFRAME_MAX + 1];
int plannedType[X265_LOOKAHEAD_MAX + 1];
int64_t plannedSatd[X265_LOOKAHEAD_MAX + 1];
+ int bframes;
/* rate control / adaptive quant data */
double* qpAqOffset; // qp Aq offset values for each Cu
@@ -134,9 +135,9 @@
uint16_t* propagateCost;
double weightedCostDelta[X265_BFRAME_MAX + 2];
- bool create(TComPicYuv *orig, int bframes, bool bAqEnabled);
- void destroy(int bframes);
- void init(TComPicYuv *orig, int poc, int sliceType, int bframes);
+ bool create(TComPicYuv *orig, int _bframes, bool bAqEnabled);
+ void destroy();
+ void init(TComPicYuv *orig, int poc, int sliceType);
};
}
diff -r 7209562f4cc8 -r b95dc6fea48c source/encoder/dpb.cpp
--- a/source/encoder/dpb.cpp Thu Mar 06 15:29:23 2014 -0600
+++ b/source/encoder/dpb.cpp Thu Mar 06 16:41:04 2014 -0800
@@ -36,7 +36,7 @@
while (!m_picList.empty())
{
TComPic* pic = m_picList.popFront();
- pic->destroy(m_cfg->param->bframes);
+ pic->destroy();
delete pic;
}
}
@@ -64,7 +64,7 @@
}
}
-void DPB::prepareEncode(TComPic *pic)
+void DPB::prepareEncode(TComPic *pic, x265_param* param)
{
PPAScopeEvent(DPB_prepareEncode);
@@ -73,8 +73,8 @@
m_picList.pushFront(*pic);
TComSlice* slice = pic->getSlice();
- 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)
+ if (getNalUnitType(pocCurr, m_lastIDR, pic, param) == NAL_UNIT_CODED_SLICE_IDR_W_RADL ||
+ getNalUnitType(pocCurr, m_lastIDR, pic, param) == NAL_UNIT_CODED_SLICE_IDR_N_LP)
{
m_lastIDR = pocCurr;
}
@@ -92,7 +92,7 @@
slice->setTemporalLayerNonReferenceFlag(!slice->isReferenced());
// Set the nal unit type
- slice->setNalUnitType(getNalUnitType(pocCurr, m_lastIDR, pic));
+ slice->setNalUnitType(getNalUnitType(pocCurr, m_lastIDR, pic, param));
// If the slice is un-referenced, change from _R "referenced" to _N "non-referenced" NAL unit type
if (slice->getTemporalLayerNonReferenceFlag())
@@ -365,7 +365,7 @@
* \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, TComPic* pic)
+NalUnitType DPB::getNalUnitType(int curPOC, int lastIDR, TComPic* pic, x265_param* param)
{
if (curPOC == 0)
{
@@ -373,7 +373,7 @@
}
if (pic->m_lowres.bKeyframe)
{
- if (m_cfg->param->bOpenGOP)
+ if (param->bOpenGOP)
{
return NAL_UNIT_CODED_SLICE_CRA;
}
diff -r 7209562f4cc8 -r b95dc6fea48c source/encoder/dpb.h
--- a/source/encoder/dpb.h Thu Mar 06 15:29:23 2014 -0600
+++ b/source/encoder/dpb.h Thu Mar 06 16:41:04 2014 -0800
@@ -41,13 +41,11 @@
int m_lastIDR;
int m_pocCRA;
bool m_bRefreshPending;
- Encoder* m_cfg;
PicList m_picList;
int m_maxRefL0;
int m_maxRefL1;
DPB(Encoder *cfg)
- : m_cfg(cfg)
{
m_lastIDR = 0;
m_pocCRA = 0;
@@ -58,7 +56,7 @@
~DPB();
- void prepareEncode(TComPic*);
+ void prepareEncode(TComPic*, x265_param* param);
void recycleUnreferenced(PicList& freeList);
@@ -71,7 +69,7 @@
void arrangeLongtermPicturesInRPS(TComSlice *);
- NalUnitType getNalUnitType(int curPoc, int lastIdr, TComPic* pic);
+ NalUnitType getNalUnitType(int curPoc, int lastIdr, TComPic* pic, x265_param* param);
};
}
diff -r 7209562f4cc8 -r b95dc6fea48c source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Thu Mar 06 15:29:23 2014 -0600
+++ b/source/encoder/encoder.cpp Thu Mar 06 16:41:04 2014 -0800
@@ -145,7 +145,7 @@
while (!m_freeList.empty())
{
TComPic* pic = m_freeList.popFront();
- pic->destroy(param->bframes);
+ pic->destroy();
delete pic;
}
@@ -296,7 +296,7 @@
x265_log(param, X265_LOG_ERROR, "memory allocation failure, aborting encode\n");
if (pic)
{
- pic->destroy(param->bframes);
+ pic->destroy();
delete pic;
}
return -1;
@@ -442,7 +442,7 @@
curEncoder->initSlice(fenc);
// determine references, setup RPS, etc
- m_dpb->prepareEncode(fenc);
+ m_dpb->prepareEncode(fenc, param);
// set slice QP
m_rateControl->rateControlStart(fenc, m_lookahead, &curEncoder->m_rce, this);
diff -r 7209562f4cc8 -r b95dc6fea48c source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp Thu Mar 06 15:29:23 2014 -0600
+++ b/source/encoder/slicetype.cpp Thu Mar 06 16:41:04 2014 -0800
@@ -78,14 +78,14 @@
while (!inputQueue.empty())
{
TComPic* pic = inputQueue.popFront();
- pic->destroy(cfg->param->bframes);
+ pic->destroy();
delete pic;
}
while (!outputQueue.empty())
{
TComPic* pic = outputQueue.popFront();
- pic->destroy(cfg->param->bframes);
+ pic->destroy();
delete pic;
}
@@ -96,7 +96,7 @@
{
TComPicYuv *orig = pic->getPicYuvOrg();
- pic->m_lowres.init(orig, pic->getSlice()->getPOC(), sliceType, cfg->param->bframes);
+ pic->m_lowres.init(orig, pic->getSlice()->getPOC(), sliceType);
inputQueue.pushBack(*pic);
if (inputQueue.size() >= cfg->param->lookaheadDepth)
More information about the x265-devel
mailing list