[x265] [PATCH] Add optional parameter to setLambdaFromQP and calculateQpForCUSize functions
Steve Borho
steve at borho.org
Thu Oct 8 21:41:52 CEST 2015
On 10/08, kavitha at multicorewareinc.com wrote:
> # HG changeset patch
> # User Kavitha Sampath <kavitha at multicorewareinc.com>
> # Date 1444306002 -19800
> # Thu Oct 08 17:36:42 2015 +0530
> # Node ID c4d4df4413b8ae67550e6f3240367b4f241cc4b2
> # Parent bd8087bfd93f7564df436a27c22f7e44f6803c4a
> 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.
nice cleanup patch. is g_depthInc[] still used anywhere, or can it be
also removed?
> diff -r bd8087bfd93f -r c4d4df4413b8 source/encoder/analysis.cpp
> --- a/source/encoder/analysis.cpp Thu Oct 08 16:28:14 2015 +0530
> +++ b/source/encoder/analysis.cpp Thu Oct 08 17:36:42 2015 +0530
> @@ -150,7 +150,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;
> @@ -161,7 +160,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;
> @@ -190,6 +189,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)
> {
> @@ -228,7 +228,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];
> @@ -302,7 +302,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);
> @@ -314,7 +314,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);
> @@ -2137,10 +2136,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 bd8087bfd93f -r c4d4df4413b8 source/encoder/analysis.h
> --- a/source/encoder/analysis.h Thu Oct 08 16:28:14 2015 +0530
> +++ b/source/encoder/analysis.h Thu Oct 08 17:36:42 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);
>
> /* check whether current mode is the new best */
> inline void checkBestMode(Mode& mode, uint32_t depth)
> diff -r bd8087bfd93f -r c4d4df4413b8 source/encoder/search.cpp
> --- a/source/encoder/search.cpp Thu Oct 08 16:28:14 2015 +0530
> +++ b/source/encoder/search.cpp Thu Oct 08 17:36:42 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 bd8087bfd93f -r c4d4df4413b8 source/encoder/search.h
> --- a/source/encoder/search.h Thu Oct 08 16:28:14 2015 +0530
> +++ b/source/encoder/search.h Thu Oct 08 17:36:42 2015 +0530
> @@ -333,7 +333,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
--
Steve Borho
More information about the x265-devel
mailing list