[x265] [PATCH] no-rdo: use bit estimates from ME to calculate RDcost

Steve Borho steve at borho.org
Wed Oct 30 20:53:01 CET 2013


On Wed, Oct 30, 2013 at 4:47 AM, <deepthidevaki at multicorewareinc.com> wrote:

> # HG changeset patch
> # User Deepthi Devaki <deepthidevaki at multicorewareinc.com>
> # Date 1383126419 -19800
> # Node ID 77db80a67f4e55f22bc02ed02930a269bfac6b50
> # Parent  74bf8634037ce3e673b21738a5ffaf1c14381414
> no-rdo: use bit estimates from ME to calculate RDcost.
>
> bits estimated in ME stored in CU and used for calculating rdcost along
> with distortion. This results in better bitrate with no-rdo, with small
> drop in PSNR.
>

I see this has been already pushed, but I'm not certain this is an
unambiguously good trade-off:

x265 sintel_trailer_2k_480p24.y4m out.hevc --rd 0  --b-adapt 2 -b3 --hash 1

before:
encoded 1253 frames in 262.32s (4.78 fps), 143.50 kb/s, Global PSNR: 48.745

after:
encoded 1253 frames in 259.50s (4.83 fps), 142.36 kb/s, Global PSNR: 48.655



> diff -r 74bf8634037c -r 77db80a67f4e source/Lib/TLibEncoder/TEncSearch.cpp
> --- a/source/Lib/TLibEncoder/TEncSearch.cpp     Wed Oct 30 13:44:16 2013
> +0530
> +++ b/source/Lib/TLibEncoder/TEncSearch.cpp     Wed Oct 30 15:16:59 2013
> +0530
> @@ -2115,7 +2115,7 @@
>   * \param bValid
>   * \returns void
>   */
> -void TEncSearch::xMergeEstimation(TComDataCU* cu, int puIdx, uint32_t&
> interDir, TComMvField* mvField, uint32_t& mergeIndex, uint32_t& outCost,
> TComMvField* mvFieldNeighbours, UChar* interDirNeighbours, int&
> numValidMergeCand)
> +void TEncSearch::xMergeEstimation(TComDataCU* cu, int puIdx, uint32_t&
> interDir, TComMvField* mvField, uint32_t& mergeIndex, uint32_t& outCost,
> uint32_t& outbits, TComMvField* mvFieldNeighbours, UChar*
> interDirNeighbours, int& numValidMergeCand)
>  {
>      uint32_t absPartIdx = 0;
>      int width = 0;
> @@ -2144,7 +2144,7 @@
>      {
>          uint32_t costCand = MAX_UINT;
>          uint32_t bitsCand = 0;
> -
> +
>          cu->getCUMvField(REF_PIC_LIST_0)->m_mv[absPartIdx] =
> mvFieldNeighbours[0 + 2 * mergeCand].mv;
>          cu->getCUMvField(REF_PIC_LIST_0)->m_refIdx[absPartIdx] =
> mvFieldNeighbours[0 + 2 * mergeCand].refIdx;
>          cu->getCUMvField(REF_PIC_LIST_1)->m_mv[absPartIdx] =
> mvFieldNeighbours[1 + 2 * mergeCand].mv;
> @@ -2160,6 +2160,7 @@
>          if (costCand < outCost)
>          {
>              outCost = costCand;
> +            outbits = bitsCand;
>              mvField[0] = mvFieldNeighbours[0 + 2 * mergeCand];
>              mvField[1] = mvFieldNeighbours[1 + 2 * mergeCand];
>              interDir = interDirNeighbours[mergeCand];
> @@ -2226,6 +2227,8 @@
>      UChar interDirNeighbours[MRG_MAX_NUM_CANDS];
>      int numValidMergeCand = 0;
>
> +    int totalmebits = 0;
> +
>      for (int partIdx = 0; partIdx < numPart; partIdx++)
>      {
>          uint32_t listCost[2] = { MAX_UINT, MAX_UINT };
> @@ -2495,7 +2498,8 @@
>
>              // find Merge result
>              uint32_t mrgCost = MAX_UINT;
> -            xMergeEstimation(cu, partIdx, mrgInterDir, mrgMvField,
> mrgIndex, mrgCost, mvFieldNeighbours, interDirNeighbours,
> numValidMergeCand);
> +            uint32_t mrgBits = 0;
> +            xMergeEstimation(cu, partIdx, mrgInterDir, mrgMvField,
> mrgIndex, mrgCost, mrgBits, mvFieldNeighbours, interDirNeighbours,
> numValidMergeCand);
>              if (mrgCost < meCost)
>              {
>                  // set Merge result
> @@ -2517,6 +2521,7 @@
>  #if CU_STAT_LOGFILE
>                  meCost += mrgCost;
>  #endif
> +                totalmebits += mrgBits;
>              }
>              else
>              {
> @@ -2530,11 +2535,18 @@
>  #if CU_STAT_LOGFILE
>                  meCost += meCost;
>  #endif
> +                totalmebits += mebits;
>              }
>          }
> +        else
> +        {
> +            totalmebits += mebits;
> +        }
>          motionCompensation(cu, predYuv, REF_PIC_LIST_X, partIdx, bLuma,
> bChroma);
>      }
>
> +    cu->m_totalBits = totalmebits;
> +
>      setWpScalingDistParam(cu, -1, REF_PIC_LIST_X);
>  }
>
> diff -r 74bf8634037c -r 77db80a67f4e source/Lib/TLibEncoder/TEncSearch.h
> --- a/source/Lib/TLibEncoder/TEncSearch.h       Wed Oct 30 13:44:16 2013
> +0530
> +++ b/source/Lib/TLibEncoder/TEncSearch.h       Wed Oct 30 15:16:59 2013
> +0530
> @@ -211,7 +211,7 @@
>      void xGetBlkBits(PartSize cuMode, bool bPSlice, int partIdx, uint32_t
> lastMode, uint32_t blockBit[3]);
>
>      void xMergeEstimation(TComDataCU* cu, int partIdx, uint32_t&
> uiInterDir,
> -                          TComMvField* pacMvField, uint32_t& mergeIndex,
> uint32_t& outCost,
> +                          TComMvField* pacMvField, uint32_t& mergeIndex,
> uint32_t& outCost, uint32_t& outbits,
>                            TComMvField* mvFieldNeighbors, UChar*
> interDirNeighbors, int& numValidMergeCand);
>
>      void xRestrictBipredMergeCand(TComDataCU* cu, uint32_t puIdx,
> TComMvField* mvFieldNeighbours,
> diff -r 74bf8634037c -r 77db80a67f4e source/encoder/compress.cpp
> --- a/source/encoder/compress.cpp       Wed Oct 30 13:44:16 2013 +0530
> +++ b/source/encoder/compress.cpp       Wed Oct 30 15:16:59 2013 +0530
> @@ -223,10 +223,12 @@
>      m_tmpResiYuv[depth]->clear();
>
>      //do motion compensation only for Luma since luma cost alone is
> calculated
> +    outTempCU->m_totalBits = 0;
>      m_search->predInterSearch(outTempCU, outPredYuv, bUseMRG, true,
> false);
>      int part = partitionFromSizes(outTempCU->getWidth(0),
> outTempCU->getHeight(0));
> -    outTempCU->m_totalCost =
> primitives.sse_pp[part](m_origYuv[depth]->getLumaAddr(),
> m_origYuv[depth]->getStride(),
> -
> outPredYuv->getLumaAddr(), outPredYuv->getStride());
> +    uint32_t distortion =
> primitives.sse_pp[part](m_origYuv[depth]->getLumaAddr(),
> m_origYuv[depth]->getStride(),
> +
>  outPredYuv->getLumaAddr(), outPredYuv->getStride());
> +    outTempCU->m_totalCost = m_rdCost->calcRdCost(distortion,
> outTempCU->m_totalBits);
>  }
>
>  void TEncCu::xComputeCostMerge2Nx2N(TComDataCU*& outBestCU, TComDataCU*&
> outTempCU, bool* earlyDetectionSkip, TComYuv*& bestPredYuv, TComYuv*&
> yuvReconBest)
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>



-- 
Steve Borho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20131030/2b169bdf/attachment.html>


More information about the x265-devel mailing list