[x265] [PATCH 3 of 6] rc: limit bit amortization in ABR to longer sequences
aarthi at multicorewareinc.com
aarthi at multicorewareinc.com
Wed Nov 26 19:41:49 CET 2014
# HG changeset patch
# User Aarthi Thirumalai
# Date 1416918660 -19800
# Tue Nov 25 18:01:00 2014 +0530
# Node ID 64207385c7b0153826df955c965228d8af3c8369
# Parent 58f220140bc59d8373d253f97959bd02541f6338
rc: limit bit amortization in ABR to longer sequences
diff -r 58f220140bc5 -r 64207385c7b0 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp Wed Nov 19 14:53:21 2014 +0530
+++ b/source/encoder/ratecontrol.cpp Tue Nov 25 18:01:00 2014 +0530
@@ -40,8 +40,7 @@
using namespace x265;
/* Amortize the partial cost of I frames over the next N frames */
-const double RateControl::s_amortizeFraction = 0.85;
-const int RateControl::s_amortizeFrames = 75;
+
const int RateControl::s_slidingWindowFrames = 20;
const char *RateControl::s_defaultStatFileName = "x265_2pass.log";
@@ -323,6 +322,12 @@
m_bTerminated = false;
m_finalFrameCount = 0;
m_numEntries = 0;
+ m_amortizeFraction = 0.85;
+ m_amortizeFrames = 75;
+ if (m_param->totalFrames <= 2 * m_fps)
+ {
+ m_amortizeFraction = m_amortizeFrames = 0;
+ }
if (m_param->rc.rateControlMode == X265_RC_CRF)
{
m_param->rc.qp = (int)m_param->rc.rfConstant;
@@ -1614,8 +1619,8 @@
if (m_partialResidualFrames)
rce->rowTotalBits += m_partialResidualCost * m_partialResidualFrames;
- m_partialResidualFrames = X265_MIN(s_amortizeFrames, m_param->keyframeMax);
- m_partialResidualCost = (int)((rce->rowTotalBits * s_amortizeFraction) /m_partialResidualFrames);
+ m_partialResidualFrames = X265_MIN(m_amortizeFrames, m_param->keyframeMax);
+ m_partialResidualCost = (int)((rce->rowTotalBits * m_amortizeFraction) /m_partialResidualFrames);
rce->rowTotalBits -= m_partialResidualCost * m_partialResidualFrames;
}
else if (m_partialResidualFrames)
@@ -2191,8 +2196,8 @@
/* previous I still had a residual; roll it into the new loan */
if (m_residualFrames)
bits += m_residualCost * m_residualFrames;
- m_residualFrames = X265_MIN(s_amortizeFrames, m_param->keyframeMax);
- m_residualCost = (int)((bits * s_amortizeFraction) / m_residualFrames);
+ m_residualFrames = X265_MIN(m_amortizeFrames, m_param->keyframeMax);
+ m_residualCost = (int)((bits * m_amortizeFraction) / m_residualFrames);
bits -= m_residualCost * m_residualFrames;
}
else if (m_residualFrames)
diff -r 58f220140bc5 -r 64207385c7b0 source/encoder/ratecontrol.h
--- a/source/encoder/ratecontrol.h Wed Nov 19 14:53:21 2014 +0530
+++ b/source/encoder/ratecontrol.h Tue Nov 25 18:01:00 2014 +0530
@@ -236,8 +236,6 @@
protected:
- static const double s_amortizeFraction;
- static const int s_amortizeFrames;
static const int s_slidingWindowFrames;
static const char *s_defaultStatFileName;
@@ -245,6 +243,8 @@
int m_partialResidualFrames;
int m_residualCost;
int m_partialResidualCost;
+ int m_amortizeFrames;
+ double m_amortizeFraction;
double getQScale(RateControlEntry *rce, double rateFactor);
double rateEstimateQscale(Frame* pic, RateControlEntry *rce); // main logic for calculating QP based on ABR
More information about the x265-devel
mailing list