[x265] [PATCH] add support for hdr-opt even when aq-mode is disabled

Pradeep Ramachandran pradeep at multicorewareinc.com
Mon Jun 12 07:44:17 CEST 2017


On Fri, Jun 9, 2017 at 5:22 PM, <gopi.satykrishna at multicorewareinc.com>
wrote:

> # HG changeset patch
> # User Gopi Satykrishna Akisetty <gopi.satykrishna at multicorewareinc.com>
> # Date 1497000305 -19800
> #      Fri Jun 09 14:55:05 2017 +0530
> # Node ID 7d2ddd4c43e6424d5f234786751e6ccebf2368fd
> # Parent  e75d5f5eeae3413057437af9f7d3ba9bc10fa3fa
> add support for hdr-opt even when aq-mode is disabled
>

Pushed to default branch


>
> diff -r e75d5f5eeae3 -r 7d2ddd4c43e6 doc/reST/cli.rst
> --- a/doc/reST/cli.rst  Mon Jun 05 15:20:44 2017 +0530
> +++ b/doc/reST/cli.rst  Fri Jun 09 14:55:05 2017 +0530
> @@ -1966,6 +1966,7 @@
>
>         Add luma and chroma offsets for HDR/WCG content.
>         Input video should be 10 bit 4:2:0. Applicable for HDR content.
> +       It is recommended to use this feature along with AQ mode.
>         Default disabled. **Experimental Feature**
>
>  .. option:: --dhdr10-info <filename>
> diff -r e75d5f5eeae3 -r 7d2ddd4c43e6 source/common/frame.cpp
> --- a/source/common/frame.cpp   Mon Jun 05 15:20:44 2017 +0530
> +++ b/source/common/frame.cpp   Fri Jun 09 14:55:05 2017 +0530
> @@ -78,7 +78,7 @@
>      }
>
>      if (m_fencPic->create(param->sourceWidth, param->sourceHeight,
> param->internalCsp) &&
> -        m_lowres.create(m_fencPic, param->bframes, !!param->rc.aqMode ||
> !!param->bAQMotion, param->rc.qgSize))
> +        m_lowres.create(m_fencPic, param->bframes, !!param->rc.aqMode ||
> !!param->bAQMotion || !!param->bHDROpt, param->rc.qgSize))
>      {
>          X265_CHECK((m_reconColCount == NULL), "m_reconColCount was
> initialized");
>          m_numRows = (m_fencPic->m_picHeight + g_maxCUSize - 1)  /
> g_maxCUSize;
> diff -r e75d5f5eeae3 -r 7d2ddd4c43e6 source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp        Mon Jun 05 15:20:44 2017 +0530
> +++ b/source/encoder/encoder.cpp        Fri Jun 09 14:55:05 2017 +0530
> @@ -2066,7 +2066,7 @@
>  {
>      bool bIsVbv = m_param->rc.vbvBufferSize > 0 &&
> m_param->rc.vbvMaxBitrate > 0;
>
> -    if (!m_param->bLossless && (m_param->rc.aqMode || bIsVbv ||
> m_param->bAQMotion))
> +    if (!m_param->bLossless && (m_param->rc.aqMode || bIsVbv ||
> m_param->bAQMotion || m_param->bHDROpt))
>      {
>          pps->bUseDQP = true;
>          pps->maxCuDQPDepth = g_log2Size[m_param->maxCUSize] -
> g_log2Size[m_param->rc.qgSize];
> @@ -2446,7 +2446,7 @@
>          x265_log(p, X265_LOG_WARNING, "limit-tu disabled, requires
> tu-inter-depth > 1\n");
>      }
>      bool bIsVbv = m_param->rc.vbvBufferSize > 0 &&
> m_param->rc.vbvMaxBitrate > 0;
> -    if (!m_param->bLossless && (m_param->rc.aqMode || bIsVbv ||
> m_param->bAQMotion))
> +    if (!m_param->bLossless && (m_param->rc.aqMode || bIsVbv ||
> m_param->bAQMotion || m_param->bHDROpt))
>      {
>          if (p->rc.qgSize < X265_MAX(8, p->minCUSize))
>          {
> diff -r e75d5f5eeae3 -r 7d2ddd4c43e6 source/encoder/ratecontrol.cpp
> --- a/source/encoder/ratecontrol.cpp    Mon Jun 05 15:20:44 2017 +0530
> +++ b/source/encoder/ratecontrol.cpp    Fri Jun 09 14:55:05 2017 +0530
> @@ -2592,7 +2592,7 @@
>      int64_t actualBits = bits;
>      Slice *slice = curEncData.m_slice;
>
> -    if (m_param->rc.aqMode || m_isVbv || m_param->bAQMotion)
> +    if (m_param->rc.aqMode || m_isVbv || m_param->bAQMotion ||
> m_param->bHDROpt)
>      {
>          if (m_isVbv && !(m_2pass && m_param->rc.rateControlMode ==
> X265_RC_CRF))
>          {
> @@ -2606,7 +2606,7 @@
>              rce->qpaRc = curEncData.m_avgQpRc;
>          }
>
> -        if (m_param->rc.aqMode || m_param->bAQMotion)
> +        if (m_param->rc.aqMode || m_param->bAQMotion || m_param->bHDROpt)
>          {
>              double avgQpAq = 0;
>              /* determine actual avg encoded QP, after AQ/cutree
> adjustments */
> diff -r e75d5f5eeae3 -r 7d2ddd4c43e6 source/encoder/slicetype.cpp
> --- a/source/encoder/slicetype.cpp      Mon Jun 05 15:20:44 2017 +0530
> +++ b/source/encoder/slicetype.cpp      Fri Jun 09 14:55:05 2017 +0530
> @@ -243,29 +243,6 @@
>                      qp_adj = strength * (X265_LOG2(X265_MAX(energy, 1)) -
> (modeOneConst + 2 * (X265_DEPTH - 8)));
>                  }
>
> -                if (param->bHDROpt)
> -                {
> -                    uint32_t sum = lumaSumCu(curFrame, blockX, blockY,
> param->rc.qgSize);
> -                    uint32_t lumaAvg = sum / (loopIncr * loopIncr);
> -                    if (lumaAvg < 301)
> -                        qp_adj += 3;
> -                    else if (lumaAvg >= 301 && lumaAvg < 367)
> -                        qp_adj += 2;
> -                    else if (lumaAvg >= 367 && lumaAvg < 434)
> -                        qp_adj += 1;
> -                    else if (lumaAvg >= 501 && lumaAvg < 567)
> -                        qp_adj -= 1;
> -                    else if (lumaAvg >= 567 && lumaAvg < 634)
> -                        qp_adj -= 2;
> -                    else if (lumaAvg >= 634 && lumaAvg < 701)
> -                        qp_adj -= 3;
> -                    else if (lumaAvg >= 701 && lumaAvg < 767)
> -                        qp_adj -= 4;
> -                    else if (lumaAvg >= 767 && lumaAvg < 834)
> -                        qp_adj -= 5;
> -                    else if (lumaAvg >= 834)
> -                        qp_adj -= 6;
> -                }
>                  if (quantOffsets != NULL)
>                      qp_adj += quantOffsets[blockXY];
>                  curFrame->m_lowres.qpAqOffset[blockXY] = qp_adj;
> @@ -276,6 +253,43 @@
>          }
>      }
>
> +    if (param->bHDROpt)
> +    {
> +        double qp_adj;
> +        blockXY = 0;
> +        for (blockY = 0; blockY < maxRow; blockY += loopIncr)
> +        {
> +            for (blockX = 0; blockX < maxCol; blockX += loopIncr)
> +            {
> +                qp_adj = 0;
> +                uint32_t sum = lumaSumCu(curFrame, blockX, blockY,
> param->rc.qgSize);
> +                uint32_t lumaAvg = sum / (loopIncr * loopIncr);
> +                if (lumaAvg < 301)
> +                    qp_adj = 3;
> +                else if (lumaAvg >= 301 && lumaAvg < 367)
> +                    qp_adj = 2;
> +                else if (lumaAvg >= 367 && lumaAvg < 434)
> +                    qp_adj = 1;
> +                else if (lumaAvg >= 501 && lumaAvg < 567)
> +                    qp_adj = -1;
> +                else if (lumaAvg >= 567 && lumaAvg < 634)
> +                    qp_adj = -2;
> +                else if (lumaAvg >= 634 && lumaAvg < 701)
> +                    qp_adj = -3;
> +                else if (lumaAvg >= 701 && lumaAvg < 767)
> +                    qp_adj = -4;
> +                else if (lumaAvg >= 767 && lumaAvg < 834)
> +                    qp_adj = -5;
> +                else if (lumaAvg >= 834)
> +                    qp_adj = -6;
> +                curFrame->m_lowres.qpAqOffset[blockXY] += qp_adj;
> +                curFrame->m_lowres.qpCuTreeOffset[blockXY] += qp_adj;
> +                curFrame->m_lowres.invQscaleFactor[blockXY] =
> x265_exp2fix8(curFrame->m_lowres.qpAqOffset[blockXY]);
> +                blockXY++;
> +            }
> +        }
> +    }
> +
>      if (param->rc.qgSize == 8)
>      {
>          for (int cuY = 0; cuY < heightInCU; cuY++)
> @@ -602,7 +616,7 @@
>      m_lastKeyframe = -m_param->keyframeMax;
>      m_sliceTypeBusy = false;
>      m_fullQueueSize = X265_MAX(1, m_param->lookaheadDepth);
> -    m_bAdaptiveQuant = m_param->rc.aqMode || m_param->bEnableWeightedPred
> || m_param->bEnableWeightedBiPred || m_param->bAQMotion;
> +    m_bAdaptiveQuant = m_param->rc.aqMode || m_param->bEnableWeightedPred
> || m_param->bEnableWeightedBiPred || m_param->bAQMotion || m_param->bHDROpt;
>
>      /* If we have a thread pool and are using --b-adapt 2, it is generally
>       * preferable to perform all motion searches for each lowres frame in
> large
> @@ -911,7 +925,7 @@
>          uint32_t widthInLowresCu = (uint32_t)m_8x8Width, heightInLowresCu
> = (uint32_t)m_8x8Height;
>          double *qp_offset = 0;
>          /* Factor in qpoffsets based on Aq/Cutree in CU costs */
> -        if (m_param->rc.aqMode || m_param->bAQMotion)
> +        if (m_param->rc.aqMode || m_param->bAQMotion || m_param->bHDROpt)
>              qp_offset = (frames[b]->sliceType == X265_TYPE_B ||
> !m_param->rc.cuTree) ? frames[b]->qpAqOffset : frames[b]->qpCuTreeOffset;
>
>          for (uint32_t row = 0; row < numCuInHeight; row++)
> @@ -1305,7 +1319,7 @@
>      CostEstimateGroup estGroup(*this, frames);
>      int64_t cost = estGroup.singleCost(p0, p1, b);
>
> -    if (m_param->rc.aqMode || m_param->bAQMotion)
> +    if (m_param->rc.aqMode || m_param->bAQMotion || m_param->bHDROpt)
>      {
>          if (m_param->rc.cuTree)
>              return frameCostRecalculate(frames, p0, p1, b);
> diff -r e75d5f5eeae3 -r 7d2ddd4c43e6 source/x265cli.h
> --- a/source/x265cli.h  Mon Jun 05 15:20:44 2017 +0530
> +++ b/source/x265cli.h  Fri Jun 09 14:55:05 2017 +0530
> @@ -502,7 +502,7 @@
>      H0("                                    format:
> G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min)\n");
>      H0("   --max-cll <string>            Emit content light level info
> SEI as \"cll,fall\" (HDR)\n");
>      H0("   --[no-]hdr                    Control dumping of HDR SEI
> packet. If max-cll or master-display has non-zero values, this is enabled.
> Default %s\n", OPT(param->bEmitHDRSEI));
> -    H0("   --[no-]hdr-opt                Add luma and chroma offsets for
> HDR/WCG content. Default %s\n", OPT(param->bHDROpt));
> +    H0("   --[no-]hdr-opt                Add luma and chroma offsets for
> HDR/WCG content. Recommended to use this along with AQ Mode. Default %s\n",
> OPT(param->bHDROpt));
>      H0("   --min-luma <integer>          Minimum luma plane value of
> input source picture\n");
>      H0("   --max-luma <integer>          Maximum luma plane value of
> input source picture\n");
>      H0("\nBitstream options:\n");
>
> _______________________________________________
> 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/20170612/09c031b7/attachment-0001.html>


More information about the x265-devel mailing list