[x265] [PATCH] rc: add slow first pass as a cli. set turbo(faster) first pass as default in 2 pass
Steve Borho
steve at borho.org
Mon Aug 4 20:38:32 CEST 2014
On 08/04, aarthi at multicorewareinc.com wrote:
> # HG changeset patch
> # User Aarthi Thirumalai
> # Date 1406899062 -19800
> # Fri Aug 01 18:47:42 2014 +0530
> # Node ID a9d11d4cf6cfbe64afe7308f95598d595ceada8b
> # Parent 8edb2a5f3379a065cfe788e798f7eec0cd3ffd49
> rc: add slow first pass as a cli. set turbo(faster) first pass as default in 2 pass.
Queued, with maxNumMergeCand=1 set for the fast first pass. Should we
also be setting rdLevel = 1 as well? That would make "turbo" mode a lot
faster.
> diff -r 8edb2a5f3379 -r a9d11d4cf6cf doc/reST/cli.rst
> --- a/doc/reST/cli.rst Mon Aug 04 01:07:48 2014 -0500
> +++ b/doc/reST/cli.rst Fri Aug 01 18:47:42 2014 +0530
> @@ -826,6 +826,25 @@
>
> **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)
in the reST files, you should use tab-stops for these text sections.
I've fixed this up.
> + 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 8edb2a5f3379 -r a9d11d4cf6cf source/CMakeLists.txt
> --- a/source/CMakeLists.txt Mon Aug 04 01:07:48 2014 -0500
> +++ b/source/CMakeLists.txt Fri Aug 01 18:47:42 2014 +0530
> @@ -19,7 +19,7 @@
> 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 8edb2a5f3379 -r a9d11d4cf6cf source/common/param.cpp
> --- a/source/common/param.cpp Mon Aug 04 01:07:48 2014 -0500
> +++ b/source/common/param.cpp Fri Aug 01 18:47:42 2014 +0530
> @@ -191,6 +191,7 @@
> 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 @@
> param->searchMethod = X265_STAR_SEARCH;
> param->bEnableTransformSkip = 1;
> param->maxNumReferences = 5;
> + param->rc.bEnableSlowFirstPass = 1;
> // TODO: optimized esa
> }
> else
> @@ -640,6 +642,7 @@
> 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,20 @@
> 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-> 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 8edb2a5f3379 -r a9d11d4cf6cf source/common/param.h
> --- a/source/common/param.h Mon Aug 04 01:07:48 2014 -0500
> +++ b/source/common/param.h Fri Aug 01 18:47:42 2014 +0530
> @@ -34,6 +34,7 @@
> void setParamAspectRatio(x265_param *p, int width, int height);
> void getParamAspectRatio(x265_param *p, int& width, int& height);
> bool parseLambdaFile(x265_param *param);
> +void x265_param_apply_fastfirstpass(x265_param *p);
>
> /* this table is kept internal to avoid confusion, since log level indices start at -1 */
> static const char * const logLevelNames[] = { "none", "error", "warning", "info", "debug", "full", 0 };
> diff -r 8edb2a5f3379 -r a9d11d4cf6cf source/encoder/api.cpp
> --- a/source/encoder/api.cpp Mon Aug 04 01:07:48 2014 -0500
> +++ b/source/encoder/api.cpp Fri Aug 01 18:47:42 2014 +0530
> @@ -55,6 +55,8 @@
> 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 8edb2a5f3379 -r a9d11d4cf6cf source/x265.cpp
> --- a/source/x265.cpp Mon Aug 04 01:07:48 2014 -0500
> +++ b/source/x265.cpp Fri Aug 01 18:47:42 2014 +0530
> @@ -198,6 +198,8 @@
> { "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 @@
> " - 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 @@
> x265_log(NULL, X265_LOG_ERROR, "failed to open bitstream file <%s> for writing\n", bitstreamfn);
> return true;
> }
> -
> return false;
> }
>
> diff -r 8edb2a5f3379 -r a9d11d4cf6cf source/x265.h
> --- a/source/x265.h Mon Aug 04 01:07:48 2014 -0500
> +++ b/source/x265.h Fri Aug 01 18:47:42 2014 +0530
> @@ -798,6 +798,9 @@
> /* 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
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
--
Steve Borho
More information about the x265-devel
mailing list