[x265] [PATCH] zone: Fix BufferRate mismatch and log unclipped BufferFillFinal into csv

Aruna Matheswaran aruna at multicorewareinc.com
Tue Feb 25 18:09:59 CET 2020


On Wed, Feb 19, 2020 at 3:28 PM Snehaa Giridharan <
snehaa at multicorewareinc.com> wrote:

> # HG changeset patch
> # User Snehaa Giridharan <snehaa at multicorewareinc.com>
> # Date 1575548701 -19800
> #      Thu Dec 05 17:55:01 2019 +0530
> # Node ID 495e78dfd32bcdeee0c48a8732eba135be12cb8e
> # Parent  ce3a4929efca3034bce12b7449d73ed2e03f9b4d
> zone: Fix BufferRate mismatch and log unclipped BufferFillFinal into csv
>
> This commit fixes
> - Mismatch in BufferRate
>
Please brief this.

> - Log UnclippedBufferFillFinal into csv when csvloglevel greater than 1
>
> diff --git a/doc/reST/cli.rst b/doc/reST/cli.rst
> --- a/doc/reST/cli.rst
> +++ b/doc/reST/cli.rst
> @@ -107,6 +107,9 @@
>
>   **BufferFillFinal** Buffer bits available after removing the frame out
> of CPB.
>
> + **UnclippedBufferFillFinal** Unclipped buffer bits available after
> removing the frame
> + out of CPB only used for csv logging purpose.
> +
>   **Latency** Latency in terms of number of frames between when the frame
>   was given in and when the frame is given out.
>
> diff --git a/source/encoder/api.cpp b/source/encoder/api.cpp
> --- a/source/encoder/api.cpp
> +++ b/source/encoder/api.cpp
> @@ -1294,6 +1294,8 @@
>                      fprintf(csvfp, "RateFactor, ");
>                  if (param->rc.vbvBufferSize)
>                      fprintf(csvfp, "BufferFill, BufferFillFinal, ");
> +                if (param->csvLogLevel >= 2)
>
Need to check if  param->rc.vbvBufferSize  is set.

> +                    fprintf(csvfp, "UnclippedBufferFillFinal, ");
>                  if (param->bEnablePsnr)
>                      fprintf(csvfp, "Y PSNR, U PSNR, V PSNR, YUV PSNR, ");
>                  if (param->bEnableSsim)
> @@ -1405,6 +1407,8 @@
>          fprintf(param->csvfpt, "%.3lf,", frameStats->rateFactor);
>      if (param->rc.vbvBufferSize)
>          fprintf(param->csvfpt, "%.3lf, %.3lf,", frameStats->bufferFill,
> frameStats->bufferFillFinal);
> +    if (param->csvLogLevel >= 2)
>
Same here.

> +        fprintf(param->csvfpt, "%.3lf,",
> frameStats->unclippedBufferFillFinal);
>      if (param->bEnablePsnr)
>          fprintf(param->csvfpt, "%.3lf, %.3lf, %.3lf, %.3lf,",
> frameStats->psnrY, frameStats->psnrU, frameStats->psnrV, frameStats->psnr);
>      if (param->bEnableSsim)
> diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp
> +++ b/source/encoder/encoder.cpp
> @@ -3012,6 +3012,8 @@
>              frameStats->ipCostRatio = curFrame->m_lowres.ipCostRatio;
>          frameStats->bufferFill = m_rateControl->m_bufferFillActual;
>          frameStats->bufferFillFinal = m_rateControl->m_bufferFillFinal;
> +        if (m_param->csvLogLevel >= 2)
> +            frameStats->unclippedBufferFillFinal =
> m_rateControl->m_unclippedBufferFillFinal;
>          frameStats->frameLatency = inPoc - poc;
>          if (m_param->rc.rateControlMode == X265_RC_CRF)
>              frameStats->rateFactor = curEncData.m_rateFactor;
> diff --git a/source/encoder/ratecontrol.cpp
> b/source/encoder/ratecontrol.cpp
> --- a/source/encoder/ratecontrol.cpp
> +++ b/source/encoder/ratecontrol.cpp
> @@ -2745,7 +2745,9 @@
>          x265_log(m_param, X265_LOG_WARNING, "poc:%d, VBV underflow (%.0f
> bits)\n", rce->poc, m_bufferFillFinal);
>
>      m_bufferFillFinal = X265_MAX(m_bufferFillFinal, 0);
> -    m_bufferFillFinal += m_bufferRate;
> +    m_bufferFillFinal += rce->bufferRate;
> +    if (m_param->csvLogLevel >= 2)
> +        m_unclippedBufferFillFinal = m_bufferFillFinal;
>
>      if (m_param->rc.bStrictCbr)
>      {
> @@ -2755,14 +2757,14 @@
>              filler += FILLER_OVERHEAD * 8;
>          }
>          m_bufferFillFinal -= filler;
> -        bufferBits = X265_MIN(bits + filler + m_bufferExcess,
> m_bufferRate);
> +        bufferBits = X265_MIN(bits + filler + m_bufferExcess,
> rce->bufferRate);
>          m_bufferExcess = X265_MAX(m_bufferExcess - bufferBits + bits +
> filler, 0);
>          m_bufferFillActual += bufferBits - bits - filler;
>      }
>      else
>      {
>          m_bufferFillFinal = X265_MIN(m_bufferFillFinal, m_bufferSize);
> -        bufferBits = X265_MIN(bits + m_bufferExcess, m_bufferRate);
> +        bufferBits = X265_MIN(bits + m_bufferExcess, rce->bufferRate);
>          m_bufferExcess = X265_MAX(m_bufferExcess - bufferBits + bits, 0);
>          m_bufferFillActual += bufferBits - bits;
>          m_bufferFillActual = X265_MIN(m_bufferFillActual, m_bufferSize);
> diff --git a/source/encoder/ratecontrol.h b/source/encoder/ratecontrol.h
> --- a/source/encoder/ratecontrol.h
> +++ b/source/encoder/ratecontrol.h
> @@ -157,6 +157,7 @@
>      double m_rateFactorConstant;
>      double m_bufferSize;
>      double m_bufferFillFinal;  /* real buffer as of the last finished
> frame */
> +    double m_unclippedBufferFillFinal; /* real unclipped buffer as of the
> last finished frame used to log in CSV*/
>      double m_bufferFill;       /* planned buffer, if all in-progress
> frames hit their bit budget */
>      double m_bufferRate;       /* # of bits added to buffer_fill after
> each frame */
>      double m_vbvMaxRate;       /* in kbps */
> diff --git a/source/x265.h b/source/x265.h
> --- a/source/x265.h
> +++ b/source/x265.h
> @@ -304,6 +304,7 @@
>      double           totalFrameTime;
>      double           vmafFrameScore;
>      double           bufferFillFinal;
> +    double           unclippedBufferFillFinal;
>
Increment X265_BUILD.

>  } x265_frame_stats;
>
>  typedef struct x265_ctu_info_t
>
> --
> *Thanks and Regards,*
> *Snehaa.G*
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>


-- 
Regards,
*Aruna Matheswaran,*
Video Codec Engineer,
Media & AI analytics BU,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20200225/322c9a40/attachment.html>


More information about the x265-devel mailing list