[x265] [PATCH] no-rdo: giving weightage to the cost of all CU's and neighbour CU's for early exit
Deepthi Nandakumar
deepthi at multicorewareinc.com
Fri Nov 8 03:33:00 CET 2013
I have a few questions.
1. Do we need so many local variables?
2. Why are we adding outTempCU->cost to totalCost and then comparing
against outBestCU->cost? That doesnt make much sense to me. AFAIk,
outTempCU does not contain any valid data - we should remove this.
3. Should we be adding costCUColocated0 and costCUColocated1 also? Adding
up spatial and temporal costs, and then comparing against a threshold
derived from spatial costs - umm, no. Lets leave these out.
4. The rest of it looks ok, logically. But now you may need to re-tune this
with different weights.
Best,
Deepthi
On Thu, Nov 7, 2013 at 4:59 PM, <sumalatha at multicorewareinc.com> wrote:
> # HG changeset patch
> # User Sumalatha Polureddy
> # Date 1383823751 -19800
> # Node ID a54b30b16e83048a7a2ef5584e1e1c9682216075
> # Parent 0a1b379be359cbcf76140ac392104c856a037c78
> no-rdo: giving weightage to the cost of all CU's and neighbour CU's for
> early exit
>
> Early exit is done when CU cost at depth "n" is lessthan sum of 60% of
> avgcost of all CU's
> and 40% of avgcost of neighbour CU's at same depth.
>
> diff -r 0a1b379be359 -r a54b30b16e83 source/Lib/TLibCommon/TComPic.cpp
> --- a/source/Lib/TLibCommon/TComPic.cpp Thu Nov 07 18:17:52 2013 +0800
> +++ b/source/Lib/TLibCommon/TComPic.cpp Thu Nov 07 16:59:11 2013 +0530
> @@ -69,6 +69,14 @@
> m_ssimCnt = 0;
> m_frameTime = 0.0;
> m_elapsedCompressTime = 0.0;
> + m_avgCost[0] = 0;
> + m_avgCost[1] = 0;
> + m_avgCost[2] = 0;
> + m_avgCost[3] = 0;
> + m_count[0] = 0;
> + m_count[1] = 0;
> + m_count[2] = 0;
> + m_count[3] = 0;
> }
>
> TComPic::~TComPic()
> diff -r 0a1b379be359 -r a54b30b16e83 source/Lib/TLibCommon/TComPic.h
> --- a/source/Lib/TLibCommon/TComPic.h Thu Nov 07 18:17:52 2013 +0800
> +++ b/source/Lib/TLibCommon/TComPic.h Thu Nov 07 16:59:11 2013 +0530
> @@ -95,6 +95,8 @@
> MD5Context m_state[3];
> uint32_t m_crc[3];
> uint32_t m_checksum[3];
> + UInt64 m_avgCost[4];
> + uint32_t m_count[4];
>
> /* SSIM values per frame */
> double m_ssim;
> diff -r 0a1b379be359 -r a54b30b16e83 source/encoder/compress.cpp
> --- a/source/encoder/compress.cpp Thu Nov 07 18:17:52 2013 +0800
> +++ b/source/encoder/compress.cpp Thu Nov 07 16:59:11 2013 +0530
> @@ -567,13 +567,14 @@
> if (bSubBranch && bTrySplitDQP && depth < g_maxCUDepth - g_addCUDepth)
> {
> #if EARLY_EXIT // turn ON this to enable early exit
> - // early exit when the RD cost of best mode at depth n is less
> than the avgerage of RD cost of the
> - // CU's(above, aboveleft, aboveright, left, colocated) at depth
> "n" of previosuly coded CU's
> + // early exit when the RD cost of best mode at depth n is less
> than the sum of avgerage of RD cost of the neighbour
> + // CU's(above, aboveleft, aboveright, left, colocated) and all
> CU's at depth "n" with weightage for each quantity
> if (outBestCU != 0)
> {
> - UInt64 costCU = 0, costCUAbove = 0, costCUAboveLeft = 0,
> costCUAboveRight = 0, costCULeft = 0, costCUColocated0 = 0,
> costCUColocated1 = 0, totalCost = 0, avgCost = 0;
> + UInt64 costCU = 0, costCUAbove = 0, costCUAboveLeft = 0,
> costCUAboveRight = 0, costCULeft = 0, costCUColocated0 = 0,
> costCUColocated1 = 0, totalCostNeigh = 0, totalCostAll = 0;
> + double avgCost = 0;
> UInt64 countCU = 0, countCUAbove = 0, countCUAboveLeft = 0,
> countCUAboveRight = 0, countCULeft = 0, countCUColocated0 = 0,
> countCUColocated1 = 0;
> - UInt64 totalCount = 0;
> + UInt64 totalCountNeigh = 0, totalCountAll = 0;
> TComDataCU* above = outTempCU->getCUAbove();
> TComDataCU* aboveLeft = outTempCU->getCUAboveLeft();
> TComDataCU* aboveRight = outTempCU->getCUAboveRight();
> @@ -614,10 +615,15 @@
> countCUColocated1 = colocated1->m_count[depth];
> }
>
> - totalCost = costCU + costCUAbove + costCUAboveLeft +
> costCUAboveRight + costCULeft + costCUColocated0 + costCUColocated1;
> - totalCount = countCU + countCUAbove + countCUAboveLeft +
> countCUAboveRight + countCULeft + countCUColocated0 + countCUColocated1;
> - if (totalCount != 0)
> - avgCost = totalCost / totalCount;
> + totalCostNeigh = costCU + costCUAbove + costCUAboveLeft +
> costCUAboveRight + costCULeft + costCUColocated0 + costCUColocated1;
> + totalCountNeigh = countCU + countCUAbove + countCUAboveLeft +
> countCUAboveRight + countCULeft + countCUColocated0 + countCUColocated1;
> +
> + totalCostAll = (outTempCU->getPic()->m_avgCost[depth] *
> outTempCU->getPic()->m_count[depth]) - totalCostNeigh;
> + totalCountAll = outTempCU->getPic()->m_count[depth] -
> totalCountNeigh;
> +
> + //giving 60% weight to all CU's and 40% weight to neighbour
> CU's
> + if (totalCountAll)
> + avgCost = ((0.6 * totalCostAll) + (0.4 * totalCostNeigh))
> / ((0.6 * totalCountAll) + (0.4 * totalCountNeigh));
>
> float lambda = 1.0f;
>
> @@ -672,6 +678,9 @@
>
> outTempCU->getPic()->getPicSym()->getCU(outTempCU->getAddr())->m_count[depth
> + 1] += 1;
> outTempCU->m_avgCost[depth + 1] = (temp +
> tempavgCost) / outTempCU->m_count[depth + 1];
>
> outTempCU->getPic()->getPicSym()->getCU(outTempCU->getAddr())->m_avgCost[depth
> + 1] = outTempCU->m_avgCost[depth + 1];
> + temp = outTempCU->getPic()->m_avgCost[depth+1] *
> outTempCU->getPic()->m_count[depth+1];
> + outTempCU->getPic()->m_count[depth+1] += 1;
> + outTempCU->getPic()->m_avgCost[depth+1] = (temp +
> tempavgCost) / outTempCU->getPic()->m_count[depth+1];
> }
> #endif // if EARLY_EXIT
> /* Adding costs from best SUbCUs */
> @@ -775,9 +784,12 @@
> UInt64 temp = outTempCU->m_avgCost[depth] *
> outTempCU->m_count[depth];
> outTempCU->m_count[depth] += 1;
>
> outTempCU->getPic()->getPicSym()->getCU(outTempCU->getAddr())->m_count[depth]
> += 1;
> -
> outTempCU->m_avgCost[depth] = (temp + tempavgCost) /
> outTempCU->m_count[depth];
>
> outTempCU->getPic()->getPicSym()->getCU(outTempCU->getAddr())->m_avgCost[depth]
> = outTempCU->m_avgCost[depth];
> +
> + temp = outTempCU->getPic()->m_avgCost[depth] *
> outTempCU->getPic()->m_count[depth];
> + outTempCU->getPic()->m_count[depth] += 1;
> + outTempCU->getPic()->m_avgCost[depth] = (temp +
> tempavgCost) / outTempCU->getPic()->m_count[depth];
> }
> if (outTempCU->m_totalCost < outBestCU->m_totalCost)
> {
> _______________________________________________
> 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/20131108/ce254aa7/attachment.html>
More information about the x265-devel
mailing list