<div dir="ltr">Queued with nit fixes.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 16, 2014 at 2:21 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 1410757433 -19800<br>
# Mon Sep 15 10:33:53 2014 +0530<br>
# Node ID 49c54a540cc237659416be7d5fb53241fb0094e4<br>
# Parent 1de67321275e70d510f0df3d5b7d4b9d391a1e66<br>
rc: fixes for 2 pass + vbv to calculate frameSizePlanned accurately.<br>
<br>
diff -r 1de67321275e -r 49c54a540cc2 source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Mon Sep 15 15:00:13 2014 +0200<br>
+++ b/source/encoder/encoder.cpp Mon Sep 15 10:33:53 2014 +0530<br>
@@ -235,13 +235,10 @@<br>
void Encoder::updateVbvPlan(RateControl* rc)<br>
{<br>
int encIdx, curIdx;<br>
-<br>
- curIdx = (m_curEncoder + m_param->frameNumThreads - 1) % m_param->frameNumThreads;<br>
- encIdx = (curIdx + 1) % m_param->frameNumThreads;<br>
- while (encIdx != curIdx)<br>
+ for ( int i = 0; i < m_param->frameNumThreads; i++)<br>
{<br>
- FrameEncoder *encoder = &m_frameEncoder[encIdx];<br>
- if (encoder->m_rce.isActive)<br>
+ FrameEncoder *encoder = &m_frameEncoder[i];<br>
+ if (encoder->m_rce.isActive && encoder->m_rce.poc != rc->m_curSlice->m_poc)<br>
{<br>
int64_t bits = (int64_t) X265_MAX(encoder->m_rce.frameSizeEstimated, encoder->m_rce.frameSizePlanned);<br>
rc->m_bufferFill -= bits;<br>
@@ -251,7 +248,6 @@<br>
if (rc->m_2pass)<br>
rc->m_predictedBits += bits;<br>
}<br>
- encIdx = (encIdx + 1) % m_param->frameNumThreads;<br>
}<br>
}<br>
<br>
diff -r 1de67321275e -r 49c54a540cc2 source/encoder/ratecontrol.cpp<br>
--- a/source/encoder/ratecontrol.cpp Mon Sep 15 15:00:13 2014 +0200<br>
+++ b/source/encoder/ratecontrol.cpp Mon Sep 15 10:33:53 2014 +0530<br>
@@ -1365,12 +1365,20 @@<br>
q += m_pbOffset;<br>
rce->qpNoVbv = q;<br>
double qScale = x265_qp2qScale(q);<br>
- if (m_leadingBframes > 5 && m_isVbv)<br>
+<br>
+ if (!m_2pass && m_isVbv)<br>
{<br>
- qScale = clipQscale(pic, qScale);<br>
- m_lastQScaleFor[m_sliceType] = qScale;<br>
+ if (m_leadingBframes > 5)<br>
+ {<br>
+ qScale = clipQscale(pic, qScale);<br>
+ m_lastQScaleFor[m_sliceType] = qScale;<br>
+ }<br>
+ rce->frameSizePlanned = predictSize(&m_predBfromP, qScale, (double)m_leadingNoBSatd);<br>
}<br>
- rce->frameSizePlanned = predictSize(&m_predBfromP, qScale, (double)m_leadingNoBSatd);<br>
+ else if (m_2pass && m_isVbv)<br>
+ {<br>
+ rce->frameSizePlanned = qScale2bits(rce, qScale);<br>
+ }<br>
rce->frameSizeEstimated = rce->frameSizePlanned;<br>
rce->newQScale = qScale;<br>
return qScale;<br>
@@ -1400,8 +1408,7 @@<br>
diff = m_predictedBits - (int64_t)rce->expectedBits;<br>
q = rce->newQScale;<br>
q /= Clip3(0.5, 2.0, (double)(abrBuffer - diff) / abrBuffer);<br>
- if (((rce->encodeOrder + 1 - m_param->frameNumThreads) >= m_fps) &&<br>
- (m_expectedBitsSum > 0))<br>
+ if (m_expectedBitsSum > 0)<br>
{<br>
/* Adjust quant based on the difference between<br>
* achieved and expected bitrate so far */<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" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br></div>