[x265] [PATCH 1 of 2] cli: remove tune cbr and introduce strict-cbr as a param option instead

Deepthi Nandakumar deepthi at multicorewareinc.com
Tue Dec 30 10:25:12 CET 2014


Thanks, need to increment X265_BUILD version number as well.

On Tue, Dec 30, 2014 at 2:51 PM, <aarthi at multicorewareinc.com> wrote:

> # HG changeset patch
> # User Aarthi Thirumalai
> # Date 1419332550 -19800
> #      Tue Dec 23 16:32:30 2014 +0530
> # Node ID 98dfd6e0c72122e8613208d5927a4c81da6a8e7a
> # Parent  32ed3f21039a5b93a54da8961442825e4db69d88
> cli: remove tune cbr and introduce strict-cbr as a param option instead
>
> strict-cbr can be enabled in CBR mode, enforces stricter checks for
> bitrate adhearance and
> lesser tolerance for bitrate deviance from the target.
>
> diff -r 32ed3f21039a -r 98dfd6e0c721 doc/reST/cli.rst
> --- a/doc/reST/cli.rst  Mon Dec 29 13:49:02 2014 +0530
> +++ b/doc/reST/cli.rst  Tue Dec 23 16:32:30 2014 +0530
> @@ -209,7 +209,7 @@
>         be applied after :option:`--preset` but before all other
> parameters. Default none.
>         See :ref:`tunings <tunings>` for more detail.
>
> -       **Values:** psnr, ssim, grain, zero-latency, fast-decode, cbr.
> +       **Values:** psnr, ssim, grain, zero-latency, fast-decode.
>
>  Input/Output File Options
>  =========================
> @@ -992,6 +992,12 @@
>         * :option:`--subme` = MIN(2, :option:`--subme`)
>         * :option:`--rd` = MIN(2, :option:`--rd`)
>
> +.. option:: --strict-cbr, --no-strict-cbr
> +
> +       Enables stricter conditions to control bitrate
> +       deviance from the target in CBR mode. Bitrate adhearance is
> prioritised
> +       over quality. Rate tolerance is set to 50%. Default disabled
> +
>  .. option:: --cbqpoffs <integer>
>
>         Offset of Cb chroma QP from the luma QP selected by rate control.
> diff -r 32ed3f21039a -r 98dfd6e0c721 source/common/param.cpp
> --- a/source/common/param.cpp   Mon Dec 29 13:49:02 2014 +0530
> +++ b/source/common/param.cpp   Tue Dec 23 16:32:30 2014 +0530
> @@ -206,6 +206,7 @@
>      param->rc.complexityBlur = 20;
>      param->rc.qblur = 0.5;
>      param->rc.bEnableSlowFirstPass = 0;
> +    param->rc.bStrictCbr = 0;
>
>      /* Video Usability Information (VUI) */
>      param->vui.aspectRatioIdc = 0;
> @@ -421,11 +422,6 @@
>              param->rc.aqStrength = 0.3;
>              param->rc.qCompress = 0.8;
>          }
> -        else if (!strcmp(tune, "cbr"))
> -        {
> -            param->rc.pbFactor = 1.0;
> -            param->rc.rateTolerance = 0.5;
> -        }
>          else
>              return -1;
>      }
> @@ -699,6 +695,12 @@
>      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("strict-cbr")
> +    {
> +        p->rc.bStrictCbr = atobool(value);
> +        p->rc.pbFactor = 1.0;
> +        p->rc.rateTolerance = 0.5;
> +    }
>      OPT("analysis-mode") p->analysisMode = parseName(value,
> x265_analysis_names, bError);
>      OPT("sar")
>      {
> @@ -1087,6 +1089,8 @@
>            "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),
> +          "Strict-cbr cannot be applied without specifying target bitrate
> or vbv bufsize");
>      return check_failed;
>  }
>
> diff -r 32ed3f21039a -r 98dfd6e0c721 source/encoder/ratecontrol.cpp
> --- a/source/encoder/ratecontrol.cpp    Mon Dec 29 13:49:02 2014 +0530
> +++ b/source/encoder/ratecontrol.cpp    Tue Dec 23 16:32:30 2014 +0530
> @@ -324,10 +324,6 @@
>      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;
> @@ -396,6 +392,11 @@
>              x265_log(m_param, X265_LOG_WARNING, "max bitrate less than
> average bitrate, assuming CBR\n");
>              m_param->rc.bitrate = m_param->rc.vbvMaxBitrate;
>          }
> +        if (m_param->rc.bStrictCbr && m_param->rc.vbvMaxBitrate !=
> m_param->rc.bitrate)
> +        {
> +            x265_log(m_param, X265_LOG_WARNING, "strict CBR set without
> CBR mode, ignored\n");
> +            m_param->rc.bStrictCbr = 0;
> +        }
>      }
>      else if (m_param->rc.vbvMaxBitrate)
>      {
> @@ -408,7 +409,11 @@
>          x265_log(m_param, X265_LOG_WARNING, "NAL HRD parameters require
> VBV parameters, ignored\n");
>          m_param->bEmitHRDSEI = 0;
>      }
> -
> +    if (m_param->totalFrames <= 2 * m_fps && m_param->rc.bStrictCbr)
> +    {
> +        m_amortizeFraction = 0;
> +        m_amortizeFrames = 0;
> +    }
>      m_isCbr = m_param->rc.rateControlMode == X265_RC_ABR && m_isVbv &&
> !m_2pass && m_param->rc.vbvMaxBitrate <= m_param->rc.bitrate;
>      m_leadingBframes = m_param->bframes;
>      m_bframeBits = 0;
> diff -r 32ed3f21039a -r 98dfd6e0c721 source/x265.cpp
> --- a/source/x265.cpp   Mon Dec 29 13:49:02 2014 +0530
> +++ b/source/x265.cpp   Tue Dec 23 16:32:30 2014 +0530
> @@ -217,6 +217,7 @@
>      { "no-slow-firstpass",    no_argument, NULL, 0 },
>      { "analysis-mode",  required_argument, NULL, 0 },
>      { "analysis-file",  required_argument, NULL, 0 },
> +    { "strict-cbr",           no_argument, NULL, 0 },
>      { 0, 0, 0, 0 }
>  };
>
> @@ -457,6 +458,7 @@
>         "                                   - 3 : Nth pass, overwrites
> stats file\n");
>      H0("   --stats                       Filename for stats file in
> multipass pass rate control. Default x265_2pass.log\n");
>      H0("   --[no-]slow-firstpass         Enable a slow first pass in a
> multipass rate control mode. Default %s\n",
> OPT(param->rc.bEnableSlowFirstPass));
> +    H0("   --[no-]strict-cbr             Enable stricter conditions and
> tolerance for bitrate deviations in CBR mode. Default %s\n",
> OPT(param->rc.bStrictCbr));
>      H0("   --analysis-mode <string|int>  save - Dump analysis info into
> file, load - Load analysis buffers from the file. Default %d\n",
> param->analysisMode);
>      H0("   --analysis-file <filename>    Specify file name used for
> either dumping or reading analysis data.\n");
>      H0("   --aq-mode <integer>           Mode for Adaptive Quantization -
> 0:none 1:uniform AQ 2:auto variance. Default %d\n", param->rc.aqMode);
> diff -r 32ed3f21039a -r 98dfd6e0c721 source/x265.h
> --- a/source/x265.h     Mon Dec 29 13:49:02 2014 +0530
> +++ b/source/x265.h     Tue Dec 23 16:32:30 2014 +0530
> @@ -875,6 +875,10 @@
>           * ignored. The lambda tables are process-global, so these new
> lambda
>           * values will affect all encoders in the same process */
>          const char* lambdaFileName;
> +
> +        /* Enable stricter conditions to check bitrate deviations in CBR
> mode. May compromise
> +           quality to maintain bitrate adhearance */
> +        int bStrictCbr;
>      } rc;
>
>      /*== Video Usability Information ==*/
> @@ -1032,7 +1036,7 @@
>   *      100 times faster than placebo!
>   *
>   *      Currently available tunings are: */
> -static const char * const x265_tune_names[] = { "psnr", "ssim", "grain",
> "zerolatency", "fastdecode", "cbr", 0 };
> +static const char * const x265_tune_names[] = { "psnr", "ssim", "grain",
> "zerolatency", "fastdecode", 0 };
>
>  /*      returns 0 on success, negative on failure (e.g. invalid
> preset/tune name). */
>  int x265_param_default_preset(x265_param *, const char *preset, const
> char *tune);
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20141230/5d3c365b/attachment-0001.html>


More information about the x265-devel mailing list