[x265] [PATCH 1 of 3] Add optional parameter to setLambdaFromQP and calculateQpForCUSize functions

Deepthi Nandakumar deepthi at multicorewareinc.com
Wed Nov 11 09:42:13 CET 2015


On Tue, Oct 27, 2015 at 11:21 AM, <kavitha at multicorewareinc.com> wrote:

> # HG changeset patch
> # User Kavitha Sampath <kavitha at multicorewareinc.com>
> # Date 1445610049 -19800
> #      Fri Oct 23 19:50:49 2015 +0530
> # Node ID 3bcefff74b44d78c65456ecff25ef10b8a710283
> # Parent  6563218ce342c30bfd4f9bc172a1dab510e6e55b
> Add optional parameter to setLambdaFromQP and calculateQpForCUSize
> functions
>
> Inaddition, the zOrder is no more passed explicitly to compressIntraCU(),
> instead used implicitly from cuGeom. This commit forms groundwork for
> QP based RD refinement.
>
> diff -r 6563218ce342 -r 3bcefff74b44 source/encoder/analysis.cpp
> --- a/source/encoder/analysis.cpp       Mon Oct 26 12:13:53 2015 +0530
> +++ b/source/encoder/analysis.cpp       Fri Oct 23 19:50:49 2015 +0530
> @@ -147,7 +147,6 @@
>
>      ProfileCUScope(ctu, totalCTUTime, totalCTUs);
>
> -    uint32_t zOrder = 0;
>      if (m_slice->m_sliceType == I_SLICE)
>      {
>          analysis_intra_data* intraDataCTU =
> (analysis_intra_data*)m_frame->m_analysisData.intraData;
> @@ -158,7 +157,7 @@
>              memcpy(ctu.m_partSize, &intraDataCTU->partSizes[ctu.m_cuAddr
> * numPartition], sizeof(char) * numPartition);
>              memcpy(ctu.m_chromaIntraDir,
> &intraDataCTU->chromaModes[ctu.m_cuAddr * numPartition], sizeof(uint8_t) *
> numPartition);
>          }
> -        compressIntraCU(ctu, cuGeom, zOrder, qp);
> +        compressIntraCU(ctu, cuGeom, qp);
>          if (m_param->analysisMode == X265_ANALYSIS_SAVE && intraDataCTU)
>          {
>              CUData* bestCU = &m_modeDepth[0].bestMode->cu;
> @@ -173,7 +172,7 @@
>          if (m_param->bIntraRefresh && m_slice->m_sliceType == P_SLICE &&
>              ctu.m_cuPelX / g_maxCUSize >=
> frame.m_encData->m_pir.pirStartCol
>              && ctu.m_cuPelX / g_maxCUSize <
> frame.m_encData->m_pir.pirEndCol)
> -            compressIntraCU(ctu, cuGeom, zOrder, qp);
> +            compressIntraCU(ctu, cuGeom, qp);
>          else if (!m_param->rdLevel)
>          {
>              /* In RD Level 0/1, copy source pixels into the reconstructed
> block so
> @@ -191,6 +190,7 @@
>              compressInterCU_rd0_4(ctu, cuGeom, qp);
>          else
>          {
> +            uint32_t zOrder = 0;
>              compressInterCU_rd5_6(ctu, cuGeom, zOrder, qp);
>              if (m_param->analysisMode == X265_ANALYSIS_SAVE &&
> m_frame->m_analysisData.interData)
>              {
> @@ -229,7 +229,7 @@
>      }
>  }
>
> -void Analysis::compressIntraCU(const CUData& parentCTU, const CUGeom&
> cuGeom, uint32_t& zOrder, int32_t qp)
> +void Analysis::compressIntraCU(const CUData& parentCTU, const CUGeom&
> cuGeom, int32_t qp)
>  {
>      uint32_t depth = cuGeom.depth;
>      ModeDepth& md = m_modeDepth[depth];
> @@ -306,7 +306,7 @@
>                  if (m_slice->m_pps->bUseDQP && nextDepth <=
> m_slice->m_pps->maxCuDQPDepth)
>                      nextQP = setLambdaFromQP(parentCTU,
> calculateQpforCuSize(parentCTU, childGeom));
>
> -                compressIntraCU(parentCTU, childGeom, zOrder, nextQP);
> +                compressIntraCU(parentCTU, childGeom, nextQP);
>
>                  // Save best CU and pred data for this sub CU
>                  splitCU->copyPartFrom(nd.bestMode->cu, childGeom,
> subPartIdx);
> @@ -318,7 +318,6 @@
>              {
>                  /* record the depth of this non-present sub-CU */
>                  splitCU->setEmptyPart(childGeom, subPartIdx);
> -                zOrder += g_depthInc[g_maxCUDepth - 1][nextDepth];
>              }
>          }
>          nextContext->store(splitPred->contexts);
> @@ -2145,10 +2144,10 @@
>      return false;
>  }
>
> -int Analysis::calculateQpforCuSize(const CUData& ctu, const CUGeom&
> cuGeom)
> +int Analysis::calculateQpforCuSize(const CUData& ctu, const CUGeom&
> cuGeom, double baseQp)
>  {
>      FrameData& curEncData = *m_frame->m_encData;
> -    double qp = curEncData.m_cuStat[ctu.m_cuAddr].baseQp;
> +    double qp = baseQp ? baseQp :
> curEncData.m_cuStat[ctu.m_cuAddr].baseQp;
>
>      /* Use cuTree offsets if cuTree enabled and frame is referenced, else
> use AQ offsets */
>      bool isReferenced = IS_REFERENCED(m_frame);
> diff -r 6563218ce342 -r 3bcefff74b44 source/encoder/analysis.h
> --- a/source/encoder/analysis.h Mon Oct 26 12:13:53 2015 +0530
> +++ b/source/encoder/analysis.h Fri Oct 23 19:50:49 2015 +0530
> @@ -111,7 +111,7 @@
>      uint32_t m_splitRefIdx[4];
>
>      /* full analysis for an I-slice CU */
> -    void compressIntraCU(const CUData& parentCTU, const CUGeom& cuGeom,
> uint32_t &zOrder, int32_t qp);
> +    void compressIntraCU(const CUData& parentCTU, const CUGeom& cuGeom,
> int32_t qp);
>
>      /* full analysis for a P or B slice CU */
>      uint32_t compressInterCU_dist(const CUData& parentCTU, const CUGeom&
> cuGeom, int32_t qp);
> @@ -141,7 +141,7 @@
>      /* generate residual and recon pixels for an entire CTU recursively
> (RD0) */
>      void encodeResidue(const CUData& parentCTU, const CUGeom& cuGeom);
>
> -    int calculateQpforCuSize(const CUData& ctu, const CUGeom& cuGeom);
> +    int calculateQpforCuSize(const CUData& ctu, const CUGeom& cuGeom,
> double baseQP = 0);
>
> I set this to -1, in order to not screw up lossless/QP=0 encodes. LGTM,
otherwise


>      /* check whether current mode is the new best */
>      inline void checkBestMode(Mode& mode, uint32_t depth)
> diff -r 6563218ce342 -r 3bcefff74b44 source/encoder/search.cpp
> --- a/source/encoder/search.cpp Mon Oct 26 12:13:53 2015 +0530
> +++ b/source/encoder/search.cpp Fri Oct 23 19:50:49 2015 +0530
> @@ -164,12 +164,12 @@
>      X265_FREE(m_tsRecon);
>  }
>
> -int Search::setLambdaFromQP(const CUData& ctu, int qp)
> +int Search::setLambdaFromQP(const CUData& ctu, int qp, int lambdaQp)
>  {
>      X265_CHECK(qp >= QP_MIN && qp <= QP_MAX_MAX, "QP used for lambda is
> out of range\n");
>
>      m_me.setQP(qp);
> -    m_rdCost.setQP(*m_slice, qp);
> +    m_rdCost.setQP(*m_slice, lambdaQp < 0 ? qp : lambdaQp);
>
>      int quantQP = x265_clip3(QP_MIN, QP_MAX_SPEC, qp);
>      m_quant.setQPforQuant(ctu, quantQP);
> diff -r 6563218ce342 -r 3bcefff74b44 source/encoder/search.h
> --- a/source/encoder/search.h   Mon Oct 26 12:13:53 2015 +0530
> +++ b/source/encoder/search.h   Fri Oct 23 19:50:49 2015 +0530
> @@ -279,7 +279,7 @@
>      ~Search();
>
>      bool     initSearch(const x265_param& param, ScalingList&
> scalingList);
> -    int      setLambdaFromQP(const CUData& ctu, int qp); /* returns real
> quant QP in valid spec range */
> +    int      setLambdaFromQP(const CUData& ctu, int qp, int lambdaQP =
> -1); /* returns real quant QP in valid spec range */
>
>      // mark temp RD entropy contexts as uninitialized; useful for finding
> loads without stores
>      void     invalidateContexts(int fromDepth);
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>



-- 
Deepthi Nandakumar
Engineering Manager, x265
Multicoreware, Inc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20151111/e4bc37ae/attachment.html>


More information about the x265-devel mailing list