[x265-commits] [x265] rc: allocate HRD SEI structures on demand, fix RCE vtable...
Steve Borho
steve at borho.org
Mon Jul 7 23:09:15 CEST 2014
details: http://hg.videolan.org/x265/rev/82963e72231b
branches:
changeset: 7237:82963e72231b
user: Steve Borho <steve at borho.org>
date: Mon Jul 07 14:25:20 2014 -0500
description:
rc: allocate HRD SEI structures on demand, fix RCE vtable/memset bug
diffstat:
source/encoder/frameencoder.cpp | 14 ++++++++++++--
source/encoder/ratecontrol.cpp | 16 ++++++++--------
source/encoder/ratecontrol.h | 4 ++--
source/encoder/sei.h | 2 ++
4 files changed, 24 insertions(+), 12 deletions(-)
diffs (104 lines):
diff -r 11c808e562b8 -r 82963e72231b source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp Thu Jul 03 15:12:45 2014 -0700
+++ b/source/encoder/frameencoder.cpp Mon Jul 07 14:25:20 2014 -0500
@@ -74,6 +74,12 @@ void FrameEncoder::destroy()
delete[] m_rows;
}
+ if (m_param->bEmitHRDSEI)
+ {
+ delete m_rce.picTimingSEI;
+ delete m_rce.hrdTiming;
+ }
+
delete[] m_outStreams;
m_frameFilter.destroy();
@@ -95,8 +101,12 @@ bool FrameEncoder::init(Encoder *top, in
m_rows = new CTURow[m_numRows];
for (int i = 0; i < m_numRows; ++i)
+ ok &= m_rows[i].create();
+
+ if (m_param->bEmitHRDSEI)
{
- ok &= m_rows[i].create();
+ m_rce.picTimingSEI = new SEIPictureTiming;
+ m_rce.hrdTiming = new HRDTiming;
}
// NOTE: 2 times of numRows because both Encoder and Filter in same queue
@@ -391,7 +401,7 @@ void FrameEncoder::compressFrame()
if (m_param->bEmitHRDSEI || !!m_param->interlaceMode)
{
- SEIPictureTiming *sei = &m_rce.picTimingSEI;
+ SEIPictureTiming *sei = m_rce.picTimingSEI;
TComVUI *vui = slice->getSPS()->getVuiParameters();
TComHRD *hrd = vui->getHrdParameters();
int poc = slice->getPOC();
diff -r 11c808e562b8 -r 82963e72231b source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp Thu Jul 03 15:12:45 2014 -0700
+++ b/source/encoder/ratecontrol.cpp Mon Jul 07 14:25:20 2014 -0500
@@ -1361,27 +1361,27 @@ int RateControl::rateControlEnd(Frame* p
if (pic->getSlice()->getPOC() == 0)
{
// access unit initialises the HRD
- rce->hrdTiming.cpbInitialAT = 0;
- rce->hrdTiming.cpbRemovalTime = m_nominalRemovalTime = (double)m_bufPeriodSEI.m_initialCpbRemovalDelay[0][0] / 90000;
+ rce->hrdTiming->cpbInitialAT = 0;
+ rce->hrdTiming->cpbRemovalTime = m_nominalRemovalTime = (double)m_bufPeriodSEI.m_initialCpbRemovalDelay[0][0] / 90000;
}
else
{
- rce->hrdTiming.cpbRemovalTime = m_nominalRemovalTime + (double)rce->picTimingSEI.m_auCpbRemovalDelay * time->getNumUnitsInTick() / time->getTimeScale();
- double cpbEarliestAT = rce->hrdTiming.cpbRemovalTime - (double)m_bufPeriodSEI.m_initialCpbRemovalDelay[0][0] / 90000;
+ rce->hrdTiming->cpbRemovalTime = m_nominalRemovalTime + (double)rce->picTimingSEI->m_auCpbRemovalDelay * time->getNumUnitsInTick() / time->getTimeScale();
+ double cpbEarliestAT = rce->hrdTiming->cpbRemovalTime - (double)m_bufPeriodSEI.m_initialCpbRemovalDelay[0][0] / 90000;
if (!pic->m_lowres.bKeyframe)
{
cpbEarliestAT -= (double)m_bufPeriodSEI.m_initialCpbRemovalDelayOffset[0][0] / 90000;
}
if (hrd->getCbrFlag(0, 0, 0))
- rce->hrdTiming.cpbInitialAT = m_prevCpbFinalAT;
+ rce->hrdTiming->cpbInitialAT = m_prevCpbFinalAT;
else
- rce->hrdTiming.cpbInitialAT = X265_MAX(m_prevCpbFinalAT, cpbEarliestAT);
+ rce->hrdTiming->cpbInitialAT = X265_MAX(m_prevCpbFinalAT, cpbEarliestAT);
}
uint32_t cpbsizeUnscale = (hrd->getCpbSizeValueMinus1(0, 0, 0) + 1) << (hrd->getCpbSizeScale() + CPB_SHIFT);
- rce->hrdTiming.cpbFinalAT = m_prevCpbFinalAT = rce->hrdTiming.cpbInitialAT + actualBits / cpbsizeUnscale;
- rce->hrdTiming.dpbOutputTime = (double)rce->picTimingSEI.m_picDpbOutputDelay * time->getNumUnitsInTick() / time->getTimeScale() + rce->hrdTiming.cpbRemovalTime;
+ rce->hrdTiming->cpbFinalAT = m_prevCpbFinalAT = rce->hrdTiming->cpbInitialAT + actualBits / cpbsizeUnscale;
+ rce->hrdTiming->dpbOutputTime = (double)rce->picTimingSEI->m_picDpbOutputDelay * time->getNumUnitsInTick() / time->getTimeScale() + rce->hrdTiming->cpbRemovalTime;
}
}
rce->isActive = false;
diff -r 11c808e562b8 -r 82963e72231b source/encoder/ratecontrol.h
--- a/source/encoder/ratecontrol.h Thu Jul 03 15:12:45 2014 -0700
+++ b/source/encoder/ratecontrol.h Mon Jul 07 14:25:20 2014 -0500
@@ -75,8 +75,8 @@ struct RateControlEntry
double frameSizeEstimated; /* hold frameSize, updated from cu level vbv rc */
bool isActive;
- SEIPictureTiming picTimingSEI;
- HRDTiming hrdTiming;
+ SEIPictureTiming *picTimingSEI;
+ HRDTiming *hrdTiming;
};
class RateControl
diff -r 11c808e562b8 -r 82963e72231b source/encoder/sei.h
--- a/source/encoder/sei.h Thu Jul 03 15:12:45 2014 -0700
+++ b/source/encoder/sei.h Mon Jul 07 14:25:20 2014 -0500
@@ -43,6 +43,8 @@ public:
* second time for the real encode. */
virtual void write(Bitstream& bs, TComSPS& sps);
+ virtual ~SEI() {}
+
protected:
enum PayloadType
More information about the x265-commits
mailing list