[x265] [PATCH] rc: recompute planned frame size when using vbv with --qpfile
Deepthi Nandakumar
deepthi at multicorewareinc.com
Wed Mar 11 10:27:11 CET 2015
On Wed, Mar 11, 2015 at 12:01 PM, <aarthi at multicorewareinc.com> wrote:
> # HG changeset patch
> # User Aarthi Thirumalai
> # Date 1425994215 -19800
> # Tue Mar 10 19:00:15 2015 +0530
> # Node ID 9b7b93384e39e90cf2d4c0c0a53213abff362f70
> # Parent 8f148ac8dbe4b68e88ceff84f40e33b29e888dc9
> rc: recompute planned frame size when using vbv with --qpfile
>
> diff -r 8f148ac8dbe4 -r 9b7b93384e39 source/encoder/ratecontrol.cpp
> --- a/source/encoder/ratecontrol.cpp Tue Mar 10 15:46:36 2015 +0530
> +++ b/source/encoder/ratecontrol.cpp Tue Mar 10 19:00:15 2015 +0530
> @@ -1067,7 +1067,15 @@
> {
> m_qp = (int32_t)(curFrame->m_forceqp + 0.5) - 1;
> m_qp = x265_clip3(QP_MIN, QP_MAX_MAX, m_qp);
> - rce->qpaRc = curEncData.m_avgQpRc = curEncData.m_avgQpAq = m_qp;
> + rce->qpaRc =curEncData.m_avgQpRc = curEncData.m_avgQpAq = m_qp;
>
w/s
> + if (m_isAbr)
> + {
> + rce->qpNoVbv = rce->qpaRc;
> + m_lastQScaleFor[m_sliceType] = x265_qp2qScale(rce->qpaRc);
> + if (rce->poc == 0)
> + m_lastQScaleFor[P_SLICE] = m_lastQScaleFor[m_sliceType]
> * fabs(m_param->rc.ipFactor);
> + rce->frameSizePlanned = predictSize(&m_pred[m_sliceType],
> rce->qpaRc, (double)m_currentSatd);
> + }
> }
> // Do not increment m_startEndOrder here. Make rateControlEnd of
> previous thread
> // to wait until rateControlUpdateStats of this frame is called
> @@ -1360,13 +1368,14 @@
> q += m_pbOffset;
>
> double qScale = x265_qp2qScale(q);
> + double lmin = 0, lmax = 0;
> if (m_isCbr)
> {
> qScale = tuneAbrQScaleFromFeedback(qScale);
> if (!m_isAbrReset)
> {
> - double lmin = m_lastQScaleFor[P_SLICE] / m_lstep;
> - double lmax = m_lastQScaleFor[P_SLICE] * m_lstep;
> + lmin = m_lastQScaleFor[P_SLICE] / m_lstep;
> + lmax = m_lastQScaleFor[P_SLICE] * m_lstep;
> qScale = x265_clip3(lmin, lmax, qScale);
> }
> q = x265_qScale2qp(qScale);
> @@ -1375,6 +1384,8 @@
> if (!m_2pass && m_isVbv)
> {
> qScale = clipQscale(curFrame, rce, qScale);
> + if (m_pred[m_sliceType].count == 1)
> + qScale = x265_clip3(lmin, lmax, qScale);
> m_lastQScaleFor[m_sliceType] = qScale;
> rce->frameSizePlanned = predictSize(&m_pred[m_sliceType],
> qScale, (double)m_currentSatd);
> }
> @@ -1460,7 +1471,7 @@
> * tolerances, the bit distribution approaches that of 2pass.
> */
>
> double overflow = 1;
> -
> + double lqmin = 0, lqmax = 0;
> m_shortTermCplxSum *= 0.5;
> m_shortTermCplxCount *= 0.5;
> m_shortTermCplxSum += m_currentSatd /
> (CLIP_DURATION(m_frameDuration) / BASE_FRAME_DURATION);
> @@ -1494,7 +1505,6 @@
> {
> if (m_param->rc.rateControlMode != X265_RC_CRF)
> {
> - double lqmin = 0, lqmax = 0;
> lqmin = m_lastQScaleFor[m_sliceType] / m_lstep;
> lqmax = m_lastQScaleFor[m_sliceType] * m_lstep;
> if (!m_partialResidualFrames)
> @@ -1520,6 +1530,8 @@
> q = x265_clip3(MIN_QPSCALE, MAX_MAX_QPSCALE, q);
> rce->qpNoVbv = x265_qScale2qp(q);
> q = clipQscale(curFrame, rce, q);
> + if (m_pred[m_sliceType].count == 1 && m_framesDone > 0)
> + q = x265_clip3(lqmin, lqmax, q);
> }
>
Can we include some explanation for these lmin/lmax changes?
> m_lastQScaleFor[m_sliceType] = q;
> if ((m_curSlice->m_poc == 0 || m_lastQScaleFor[P_SLICE] < q) &&
> !(m_2pass && !m_isVbv))
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20150311/d7f82f53/attachment-0001.html>
More information about the x265-devel
mailing list