<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 24, 2015 at 1:56 PM, <span dir="ltr"><<a href="mailto:aarthi@multicorewareinc.com" target="_blank">aarthi@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Aarthi Thirumalai<br>
# Date 1442909407 -19800<br>
# Tue Sep 22 13:40:07 2015 +0530<br>
# Branch stable<br>
# Node ID c44b32bc7c906456ad242dd237831ec96c1f5c3d<br>
# Parent 69d55d4c53ebff6d98e4431e0f8fe6103705b8ec<br>
rc: don't update predictors from previous frames, after reset at scenecut.<br>
<br>
diff -r 69d55d4c53eb -r c44b32bc7c90 source/encoder/ratecontrol.cpp<br>
--- a/source/encoder/ratecontrol.cpp Tue Sep 22 13:33:13 2015 +0530<br>
+++ b/source/encoder/ratecontrol.cpp Tue Sep 22 13:40:07 2015 +0530<br>
@@ -182,6 +182,7 @@<br>
m_finalFrameCount = 0;<br>
m_numEntries = 0;<br>
m_isSceneTransition = false;<br>
+ m_lastPredictorReset = 0;<br>
if (m_param->rc.rateControlMode == X265_RC_CRF)<br>
{<br>
m_param->rc.qp = (int)m_param->rc.rfConstant;<br>
@@ -370,20 +371,8 @@<br>
m_accumPNorm = .01;<br>
m_accumPQp = (m_param->rc.rateControlMode == X265_RC_CRF ? CRF_INIT_QP : ABR_INIT_QP_MIN) * m_accumPNorm;<br>
<br>
- /* Frame Predictors and Row predictors used in vbv */<br>
- for (int i = 0; i < 4; i++)<br>
- {<br>
- m_pred[i].coeff = 1.0;<br>
- m_pred[i].count = 1.0;<br>
- m_pred[i].decay = 0.5;<br>
- m_pred[i].offset = 0.0;<br>
- }<br>
- m_pred[0].coeff = m_pred[3].coeff = 0.75;<br>
- if (m_param->rc.qCompress >= 0.8) // when tuned for grain<br>
- {<br>
- m_pred[1].coeff = 0.75;<br>
- m_pred[0].coeff = m_pred[3].coeff = 0.50;<br>
- }<br>
+ /* Frame Predictors used in vbv */<br>
+ initFramePredictors();<br>
if (!m_statFileOut && (m_param->rc.bStatWrite || m_param->rc.bStatRead))<br>
{<br>
/* If the user hasn't defined the stat filename, use the default value */<br>
@@ -932,6 +921,24 @@<br>
return X265_TYPE_AUTO;<br>
}<br>
<br>
+void RateControl::initFramePredictors()<br>
+{<br>
+ /* Frame Predictors used in vbv */<br>
+ for (int i = 0; i < 4; i++)<br>
+ {<br>
+ m_pred[i].coeff = 1.0;<br>
+ m_pred[i].count = 1.0;<br>
+ m_pred[i].decay = 0.5;<br>
+ m_pred[i].offset = 0.0;<br>
+ }<br>
+ m_pred[0].coeff = m_pred[3].coeff = 0.75;<br>
+ if (m_param->rc.qCompress >= 0.8) // when tuned for grain<br>
+ {<br>
+ m_pred[1].coeff = 0.75;<br>
+ m_pred[0].coeff = m_pred[3].coeff = 0.50;<br>
+ }<br>
+}<br>
+<br>
int RateControl::rateControlStart(Frame* curFrame, RateControlEntry* rce, Encoder* enc)<br>
{<br>
int orderValue = m_startEndOrder.get();<br>
@@ -961,23 +968,21 @@<br>
copyRceData(rce, &m_rce2Pass[rce->poc]);<br>
}<br>
rce->isActive = true;<br>
- bool isframeAfterKeyframe = m_sliceType != I_SLICE && m_curSlice->m_refPicList[0][0]->m_encData->m_slice->m_sliceType == I_SLICE;<br>
+ bool isRefFrameScenecut = m_sliceType!= I_SLICE && m_curSlice->m_refPicList[0][0]->m_lowres.bScenecut == 1;<br>
if (curFrame->m_lowres.bScenecut)<br>
{<br></blockquote><div><br>This should be if (isRefFrameScenecut)?<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
m_isSceneTransition = true;<br>
- /* Frame Predictors and Row predictors used in vbv */<br>
- for (int i = 0; i < 4; i++)<br>
- {<br>
- m_pred[i].coeff = 1.0;<br>
- m_pred[i].count = 1.0;<br>
- m_pred[i].decay = 0.5;<br>
- m_pred[i].offset = 0.0;<br>
- }<br>
- m_pred[0].coeff = m_pred[3].coeff = 0.75;<br>
+ m_lastPredictorReset = rce->encodeOrder;<br>
+ initFramePredictors();<br>
}<br>
- else if (m_sliceType != B_SLICE && !isframeAfterKeyframe)<br>
+ else if (m_sliceType != B_SLICE && !isRefFrameScenecut)<br>
m_isSceneTransition = false;<br>
<br>
+ if (rce->encodeOrder < m_lastPredictorReset + m_param->frameNumThreads)<br>
+ {<br>
+ rce->rowPreds[0][0].count = 0;<br>
+ }<br>
+<br>
rce->bLastMiniGopBFrame = curFrame->m_lowres.bLastMiniGopBFrame;<br>
rce->bufferRate = m_bufferRate;<br>
rce->rowCplxrSum = 0.0;<br>
@@ -2149,7 +2154,7 @@<br>
{<br>
int predType = rce->sliceType;<br>
predType = rce->sliceType == B_SLICE && rce->keptAsRef ? 3 : predType;<br>
- if (rce->lastSatd >= m_ncu)<br>
+ if (rce->lastSatd >= m_ncu && rce->encodeOrder >= m_lastPredictorReset)<br>
updatePredictor(&m_pred[predType], x265_qp2qScale(rce->qpaRc), (double)rce->lastSatd, (double)bits);<br>
if (!m_isVbv)<br>
return;<br>
diff -r 69d55d4c53eb -r c44b32bc7c90 source/encoder/ratecontrol.h<br>
--- a/source/encoder/ratecontrol.h Tue Sep 22 13:33:13 2015 +0530<br>
+++ b/source/encoder/ratecontrol.h Tue Sep 22 13:40:07 2015 +0530<br>
@@ -173,6 +173,7 @@<br>
int m_numBframesInPattern;<br>
bool m_isPatternPresent;<br>
bool m_isSceneTransition;<br>
+ int m_lastPredictorReset;<br>
<br>
/* a common variable on which rateControlStart, rateControlEnd and rateControUpdateStats waits to<br>
* sync the calls to these functions. For example<br>
@@ -257,6 +258,7 @@<br>
void checkAndResetABR(RateControlEntry* rce, bool isFrameDone);<br>
double predictRowsSizeSum(Frame* pic, RateControlEntry* rce, double qpm, int32_t& encodedBits);<br>
bool initPass2();<br>
+ void initFramePredictors();<br>
double getDiffLimitedQScale(RateControlEntry *rce, double q);<br>
double countExpectedBits();<br>
bool vbv2Pass(uint64_t allAvailableBits);<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br></div></div>