Skip to content

Commit

Permalink
rc: modify the condition for enabling 2pass in CRF mode
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Divya committed Feb 9, 2016
1 parent 50cb283 commit fe03d19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 0 additions & 2 deletions source/common/param.cpp
Expand Up @@ -1196,8 +1196,6 @@ int x265_check_params(x265_param* param)
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),
Expand Down
11 changes: 8 additions & 3 deletions source/encoder/ratecontrol.cpp
Expand Up @@ -212,7 +212,7 @@ RateControl::RateControl(x265_param& p)
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;
Expand Down Expand Up @@ -417,7 +417,7 @@ bool RateControl::init(const SPS& sps)
return false;
}
{
int i, j;
int i, j, m;
uint32_t k , l;
bool bErr = false;
char *opts = statsBuf;
Expand All @@ -439,6 +439,11 @@ bool RateControl::init(const SPS& sps)
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",
Expand Down Expand Up @@ -564,7 +569,7 @@ bool RateControl::init(const SPS& sps)
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;
Expand Down

0 comments on commit fe03d19

Please sign in to comment.