[x265] [PATCH] rc: modify the condition for enabling 2pass in CRF mode
Divya Manivannan
divya at multicorewareinc.com
Tue Feb 9 07:38:56 CET 2016
# HG changeset patch
# User Divya Manivannan <divya at multicorewareinc.com>
# Date 1454999742 -19800
# Tue Feb 09 12:05:42 2016 +0530
# Node ID 31f23001e08fe7ed06cfe3033ecff0aa6648c509
# Parent 8e093e85b9ab4ae9af0a5240ee06ff1842d70fb1
rc: modify the condition for enabling 2pass in CRF mode
diff -r 8e093e85b9ab -r 31f23001e08f source/common/param.cpp
--- a/source/common/param.cpp Fri Feb 05 10:50:24 2016 +0530
+++ b/source/common/param.cpp Tue Feb 09 12:05:42 2016 +0530
@@ -1196,8 +1196,6 @@
CHECK(0 > param->noiseReductionIntra || param->noiseReductionIntra > 2000, "Valid noise reduction range 0 - 2000");
if (param->noiseReductionInter)
CHECK(0 > param->noiseReductionInter || param->noiseReductionInter > 2000, "Valid noise reduction range 0 - 2000");
- CHECK(param->rc.rateControlMode == X265_RC_CRF && param->rc.bStatRead && param->rc.vbvMaxBitrate == 0,
- "Constant rate-factor is incompatible with 2pass");
CHECK(param->rc.rateControlMode == X265_RC_CQP && param->rc.bStatRead,
"Constant QP is incompatible with 2pass");
CHECK(param->rc.bStrictCbr && (param->rc.bitrate <= 0 || param->rc.vbvBufferSize <=0),
diff -r 8e093e85b9ab -r 31f23001e08f source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp Fri Feb 05 10:50:24 2016 +0530
+++ b/source/encoder/ratecontrol.cpp Tue Feb 09 12:05:42 2016 +0530
@@ -212,7 +212,7 @@
m_rateFactorMaxDecrement = m_param->rc.rfConstant - m_param->rc.rfConstantMin;
}
m_isAbr = m_param->rc.rateControlMode != X265_RC_CQP && !m_param->rc.bStatRead;
- m_2pass = (m_param->rc.rateControlMode == X265_RC_ABR || m_param->rc.vbvMaxBitrate > 0) && m_param->rc.bStatRead;
+ m_2pass = m_param->rc.rateControlMode != X265_RC_CQP && m_param->rc.bStatRead;
m_bitrate = m_param->rc.bitrate * 1000;
m_frameDuration = (double)m_param->fpsDenom / m_param->fpsNum;
m_qp = m_param->rc.qp;
@@ -417,7 +417,7 @@
return false;
}
{
- int i, j;
+ int i, j, m;
uint32_t k , l;
bool bErr = false;
char *opts = statsBuf;
@@ -439,6 +439,11 @@
x265_log(m_param, X265_LOG_ERROR, "fps specified in stats file not valid\n");
return false;
}
+ if (((p = strstr(opts, " vbv-maxrate=")) == 0 || sscanf(p, " vbv-maxrate=%d", &m) != 1) && m_param->rc.rateControlMode == X265_RC_CRF)
+ {
+ x265_log(m_param, X265_LOG_ERROR, "Constant rate-factor is incompatible with 2pass without vbv-maxrate in the previous pass\n");
+ return false;
+ }
if (k != m_param->fpsNum || l != m_param->fpsDenom)
{
x265_log(m_param, X265_LOG_ERROR, "fps mismatch with 1st pass (%u/%u vs %u/%u)\n",
@@ -564,7 +569,7 @@
p = next;
}
X265_FREE(statsBuf);
- if (m_param->rc.rateControlMode == X265_RC_ABR || m_param->rc.vbvMaxBitrate > 0)
+ if (m_param->rc.rateControlMode != X265_RC_CQP)
{
if (!initPass2())
return false;
More information about the x265-devel
mailing list