[x265-commits] [x265] pixelharness: fix MSVC warning about intptr_t conversion ...
Steve Borho
steve at borho.org
Mon Aug 4 20:42:50 CEST 2014
details: http://hg.videolan.org/x265/rev/a2095baa3cbd
branches:
changeset: 7713:a2095baa3cbd
user: Steve Borho <steve at borho.org>
date: Sun Aug 03 19:14:17 2014 -0500
description:
pixelharness: fix MSVC warning about intptr_t conversion to int
Subject: [x265] psy-rdoq: include psy-cost in uncoded coefficient distortion
details: http://hg.videolan.org/x265/rev/8edb2a5f3379
branches:
changeset: 7714:8edb2a5f3379
user: Steve Borho <steve at borho.org>
date: Mon Aug 04 01:07:48 2014 -0500
description:
psy-rdoq: include psy-cost in uncoded coefficient distortion
Without this adjustment, uncoded coefficients were possibly being penalized
over coded ones with less psy value.
Subject: [x265] bugfix: disable aq only when both aq-strength and cu-tree is off
details: http://hg.videolan.org/x265/rev/44eb5e05423a
branches:
changeset: 7715:44eb5e05423a
user: Santhoshini Sekar <santhoshini at multicorewareinc.com>
date: Mon Aug 04 11:54:42 2014 +0530
description:
bugfix: disable aq only when both aq-strength and cu-tree is off
AQ can be on when cutree is on even if aq-strength is 0.Do not force aq to be
off whenever aq strength is 0.
Subject: [x265] rc: add slow first pass as option. set turbo first pass as default in 2 pass
details: http://hg.videolan.org/x265/rev/c5f2a20e6f4c
branches:
changeset: 7716:c5f2a20e6f4c
user: Aarthi Thirumalai
date: Fri Aug 01 18:47:42 2014 +0530
description:
rc: add slow first pass as option. set turbo first pass as default in 2 pass
diffstat:
doc/reST/cli.rst | 19 +++++++++++++++++++
source/CMakeLists.txt | 2 +-
source/common/param.cpp | 18 ++++++++++++++++++
source/common/param.h | 1 +
source/common/quant.cpp | 19 ++++++++++---------
source/encoder/api.cpp | 2 ++
source/encoder/encoder.cpp | 3 ---
source/test/pixelharness.cpp | 2 +-
source/x265.cpp | 4 +++-
source/x265.h | 3 +++
10 files changed, 58 insertions(+), 15 deletions(-)
diffs (244 lines):
diff -r 774dc8b6a535 -r c5f2a20e6f4c doc/reST/cli.rst
--- a/doc/reST/cli.rst Sun Aug 03 18:09:12 2014 -0500
+++ b/doc/reST/cli.rst Fri Aug 01 18:47:42 2014 +0530
@@ -826,6 +826,25 @@ Quality, rate control and rate distortio
**Range of values:** -12 to 12
+.. option:: --pass <integer>
+
+ Enable multipass rate control mode. Input is encoded multiple times,
+ storing the encoded information of each pass in a stats file from which
+ the consecutive pass tunes the qp of each frame to improve the quality
+ of the output.Default 0(disabled)
+
+ 1. First pass, cretes stats file
+ 2. Last pass, does not overwrite stats file
+ 3. Nth pass, overwrites stats file
+
+ **Range of values:** 1 to 3
+
+.. option:: --slow-firstpass, --no-slow-firstpass
+
+ Enable a slow and more detailed first pass encode in Multipass rate control mode.
+ Speed of the first pass encode is slightly lesser and quality midly improved when
+ compared to the default settings in a multipass encode. Default disabled
+
Loop filters
============
diff -r 774dc8b6a535 -r c5f2a20e6f4c source/CMakeLists.txt
--- a/source/CMakeLists.txt Sun Aug 03 18:09:12 2014 -0500
+++ b/source/CMakeLists.txt Fri Aug 01 18:47:42 2014 +0530
@@ -19,7 +19,7 @@ include(CheckSymbolExists)
include(CheckCXXCompilerFlag)
# X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 29)
+set(X265_BUILD 30)
configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
"${PROJECT_BINARY_DIR}/x265.def")
configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r 774dc8b6a535 -r c5f2a20e6f4c source/common/param.cpp
--- a/source/common/param.cpp Sun Aug 03 18:09:12 2014 -0500
+++ b/source/common/param.cpp Fri Aug 01 18:47:42 2014 +0530
@@ -191,6 +191,7 @@ void x265_param_default(x265_param *para
param->rc.statFileName = NULL;
param->rc.complexityBlur = 20;
param->rc.qblur = 0.5;
+ param->rc.bEnableSlowFirstPass = 0;
/* Quality Measurement Metrics */
param->bEnablePsnr = 0;
@@ -351,6 +352,7 @@ int x265_param_default_preset(x265_param
param->searchMethod = X265_STAR_SEARCH;
param->bEnableTransformSkip = 1;
param->maxNumReferences = 5;
+ param->rc.bEnableSlowFirstPass = 1;
// TODO: optimized esa
}
else
@@ -640,6 +642,7 @@ int x265_param_parse(x265_param *p, cons
OPT("input-csp") p->internalCsp = parseName(value, x265_source_csp_names, bError);
OPT("me") p->searchMethod = parseName(value, x265_motion_est_names, bError);
OPT("cutree") p->rc.cuTree = atobool(value);
+ OPT("slow-firstpass") p->rc.bEnableSlowFirstPass = atobool(value);
OPT("sar")
{
p->vui.aspectRatioIdc = parseName(value, x265_sar_names, bError);
@@ -1020,6 +1023,21 @@ int x265_check_params(x265_param *param)
return check_failed;
}
+void x265_param_apply_fastfirstpass(x265_param* param)
+{
+ /* Set faster options in case of turbo firstpass */
+ if (param->rc.bStatWrite && !param->rc.bStatRead)
+ {
+ param->maxNumReferences = 1;
+ param->maxNumMergeCand = 1;
+ param->bEnableRectInter = 0;
+ param->bEnableAMP = 0;
+ param->searchMethod = X265_DIA_SEARCH;
+ param->subpelRefine = X265_MIN(2, param->subpelRefine);
+ param->bEnableEarlySkip = 1;
+ }
+}
+
int x265_set_globals(x265_param *param)
{
uint32_t maxCUDepth = (uint32_t)g_convertToBit[param->maxCUSize];
diff -r 774dc8b6a535 -r c5f2a20e6f4c source/common/param.h
--- a/source/common/param.h Sun Aug 03 18:09:12 2014 -0500
+++ b/source/common/param.h Fri Aug 01 18:47:42 2014 +0530
@@ -28,6 +28,7 @@ namespace x265 {
int x265_check_params(x265_param *param);
int x265_set_globals(x265_param *param);
void x265_print_params(x265_param *param);
+void x265_param_apply_fastfirstpass(x265_param *p);
char* x265_param2string(x265_param *param);
int x265_atoi(const char *str, bool& bError);
int parseCpuName(const char *value, bool& bError);
diff -r 774dc8b6a535 -r c5f2a20e6f4c source/common/quant.cpp
--- a/source/common/quant.cpp Sun Aug 03 18:09:12 2014 -0500
+++ b/source/common/quant.cpp Fri Aug 01 18:47:42 2014 +0530
@@ -569,6 +569,8 @@ uint32_t Quant::rdoQuant(TComDataCU* cu,
double scaleFactor = errScale[blkPos]; /* (1 << scaleBits) / (quantCoef * quantCoef) */
int levelScaled = scaledCoeff[blkPos]; /* abs(coef) * quantCoef */
uint32_t maxAbsLevel = abs(dstCoeff[blkPos]); /* abs(coef) */
+ int signCoef = m_resiDctCoeff[blkPos];
+ int predictedCoef = m_fencDctCoeff[blkPos] - signCoef;
/* RDOQ measures distortion as the scaled level squared times a
* scale factor which tries to remove the quantCoef back out, but
@@ -576,6 +578,10 @@ uint32_t Quant::rdoQuant(TComDataCU* cu,
/* cost of not coding this coefficient (no signal bits) */
costUncoded[scanPos] = ((uint64_t)levelScaled * levelScaled) * scaleFactor;
+ if (usePsy && blkPos)
+ /* when no coefficient is coded, predicted coef == recon coef */
+ costUncoded[scanPos] -= (int)(((m_psyRdoqScale * predictedCoef) << scaleBits) >> 8);
+
totalUncodedCost += costUncoded[scanPos];
if (maxAbsLevel && lastScanPos < 0)
@@ -624,8 +630,7 @@ uint32_t Quant::rdoQuant(TComDataCU* cu,
if (maxAbsLevel < 3)
{
/* set default costs to uncoded costs.
- * TODO: is there really a need to check maxAbsLevel < 3 here?
- * TODO: psy cost not considered for level = 0 */
+ * TODO: is there really a need to check maxAbsLevel < 3 here? */
costSig[scanPos] = lambda2 * m_estBitsSbac.significantBits[ctxSig][0];
costCoeff[scanPos] = costUncoded[scanPos] + costSig[scanPos];
}
@@ -634,9 +639,6 @@ uint32_t Quant::rdoQuant(TComDataCU* cu,
}
if (maxAbsLevel)
{
- int signCoef = m_resiDctCoeff[blkPos];
- int predictedCoef = m_fencDctCoeff[blkPos] - signCoef;
-
const int64_t err1 = levelScaled - ((int64_t)maxAbsLevel << qbits);
double err2 = (double)(err1 * err1);
@@ -647,18 +649,17 @@ uint32_t Quant::rdoQuant(TComDataCU* cu,
double curCost = err2 * scaleFactor + lambda2 * (codedSigBits + rateCost + IEP_RATE);
// Psy RDOQ: bias in favor of higher AC coefficients in the reconstructed frame
- int psyValue = 0;
if (usePsy && blkPos)
{
int unquantAbsLevel = (lvl * (unquantScale[blkPos] << per) + unquantRound) >> unquantShift;
int reconCoef = abs(unquantAbsLevel + SIGN(predictedCoef, signCoef));
- psyValue = (int)(((m_psyRdoqScale * reconCoef) << scaleBits) >> 8);
+ curCost -= (int)(((m_psyRdoqScale * reconCoef) << scaleBits) >> 8);
}
- if (curCost - psyValue < costCoeff[scanPos])
+ if (curCost < costCoeff[scanPos])
{
level = lvl;
- costCoeff[scanPos] = curCost - psyValue;
+ costCoeff[scanPos] = curCost;
costSig[scanPos] = lambda2 * codedSigBits;
}
diff -r 774dc8b6a535 -r c5f2a20e6f4c source/encoder/api.cpp
--- a/source/encoder/api.cpp Sun Aug 03 18:09:12 2014 -0500
+++ b/source/encoder/api.cpp Fri Aug 01 18:47:42 2014 +0530
@@ -55,6 +55,8 @@ x265_encoder *x265_encoder_open(x265_par
Encoder *encoder = new Encoder;
if (encoder)
{
+ if (!param->rc.bEnableSlowFirstPass)
+ x265_param_apply_fastfirstpass(param);
// may change params for auto-detect, etc
encoder->configure(param);
diff -r 774dc8b6a535 -r c5f2a20e6f4c source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Sun Aug 03 18:09:12 2014 -0500
+++ b/source/encoder/encoder.cpp Fri Aug 01 18:47:42 2014 +0530
@@ -1330,9 +1330,6 @@ void Encoder::configure(x265_param *p)
if (p->rc.aqMode == X265_AQ_NONE && p->rc.cuTree == 0)
p->rc.aqStrength = 0;
- if (p->rc.aqStrength == 0)
- p->rc.aqMode = 0;
-
if (p->internalCsp != X265_CSP_I420)
{
x265_log(p, X265_LOG_WARNING, "!! HEVC Range Extension specifications are not finalized !!\n");
diff -r 774dc8b6a535 -r c5f2a20e6f4c source/test/pixelharness.cpp
--- a/source/test/pixelharness.cpp Sun Aug 03 18:09:12 2014 -0500
+++ b/source/test/pixelharness.cpp Fri Aug 01 18:47:42 2014 +0530
@@ -619,7 +619,7 @@ bool PixelHarness::check_cvt16to32_cnt_t
memset(ref_dest, 0xCD, sizeof(ref_dest));
memset(opt_dest, 0xCD, sizeof(opt_dest));
#endif
- int opt_cnt = checked(opt, opt_dest, sbuf1 + j, stride);
+ int opt_cnt = (int)checked(opt, opt_dest, sbuf1 + j, stride);
int ref_cnt = ref(ref_dest, sbuf1 + j, stride);
if ((ref_cnt != opt_cnt) || memcmp(ref_dest, opt_dest, 64 * 64 * sizeof(int32_t)))
diff -r 774dc8b6a535 -r c5f2a20e6f4c source/x265.cpp
--- a/source/x265.cpp Sun Aug 03 18:09:12 2014 -0500
+++ b/source/x265.cpp Fri Aug 01 18:47:42 2014 +0530
@@ -198,6 +198,8 @@ static const struct option long_options[
{ "nr", required_argument, NULL, 0 },
{ "stats", required_argument, NULL, 0 },
{ "pass", required_argument, NULL, 0 },
+ { "slow-firstpass", no_argument, NULL, 0 },
+ { "no-slow-firstpass", no_argument, NULL, 0 },
{ 0, 0, 0, 0 }
};
@@ -426,6 +428,7 @@ void CLIOptions::showHelp(x265_param *pa
" - 1 : First pass, cretes stats file\n"
" - 2 : Last pass, does not overwrite stats file\n"
" - 3 : Nth pass, overwrites stats file\n");
+ H0(" --[no-]slow-firstpass Enable a slow first pass in a multipass rate control mode. Default %s\n", OPT(param->rc.bEnableSlowFirstPass));
H0(" --scaling-list <string> Specify a file containing HM style quant scaling lists or 'default' or 'off'. Default: off\n");
H0(" --lambda-file <string> Specify a file containing replacement values for the lambda tables\n");
H0(" MAX_MAX_QP+1 floats for lambda table, then again for lambda2 table\n");
@@ -719,7 +722,6 @@ bool CLIOptions::parse(int argc, char **
x265_log(NULL, X265_LOG_ERROR, "failed to open bitstream file <%s> for writing\n", bitstreamfn);
return true;
}
-
return false;
}
diff -r 774dc8b6a535 -r c5f2a20e6f4c source/x265.h
--- a/source/x265.h Sun Aug 03 18:09:12 2014 -0500
+++ b/source/x265.h Fri Aug 01 18:47:42 2014 +0530
@@ -798,6 +798,9 @@ typedef struct x265_param
/* temporally blur complexity */
double complexityBlur;
+ /* Enable slow and a more detailed first pass encode in multi pass rate control */
+ int bEnableSlowFirstPass;
+
/* specify a text file which contains MAX_MAX_QP + 1 floating point
* values to be copied into x265_lambda_tab and a second set of
* MAX_MAX_QP + 1 floating point values for x265_lambda2_tab. All values
More information about the x265-commits
mailing list