[x265] [PATCH RFC] psyrd: use psyrdcost for selecting best mode across depth

Deepthi Nandakumar deepthi at multicorewareinc.com
Mon May 26 13:17:51 CEST 2014


But this patch sets m_psyCost = psyRdCost everywhere?


On Mon, May 26, 2014 at 4:44 PM, Sumalatha Polureddy <
sumalatha at multicorewareinc.com> wrote:

>
>
>
> On Mon, May 26, 2014 at 4:26 PM, Deepthi Nandakumar <
> deepthi at multicorewareinc.com> wrote:
>
>>
>>
>>
>> On Mon, May 26, 2014 at 3:02 PM, <sumalatha at multicorewareinc.com> wrote:
>>
>>> # HG changeset patch
>>> # User Sumalatha Polureddy<sumalatha at multicorewareinc.com>
>>> # Date 1401087565 -19800
>>> # Node ID cbe5cc0e48b4122518ca732a1b32de16ba25c467
>>> # Parent  5134e76aa729b6fece18701fdc00390c2f2ffb32
>>> psyrd: use psyrdcost for selecting best mode across depth
>>>
>>> diff -r 5134e76aa729 -r cbe5cc0e48b4 source/Lib/TLibCommon/TComDataCU.cpp
>>> --- a/source/Lib/TLibCommon/TComDataCU.cpp      Thu May 22 21:46:21 2014
>>> -0500
>>> +++ b/source/Lib/TLibCommon/TComDataCU.cpp      Mon May 26 12:29:25 2014
>>> +0530
>>> @@ -218,6 +218,7 @@
>>>      m_sa8dCost         = MAX_INT64;
>>>      m_totalDistortion  = 0;
>>>      m_totalBits        = 0;
>>> +    m_psyCost          = 0;
>>>      m_numPartitions    = pic->getNumPartInCU();
>>>      char* qp           = pic->getCU(getAddr())->getQP();
>>>      m_baseQp           = pic->getCU(getAddr())->m_baseQp;
>>> @@ -309,6 +310,7 @@
>>>      m_sa8dCost         = MAX_INT64;
>>>      m_totalDistortion  = 0;
>>>      m_totalBits        = 0;
>>> +    m_psyCost          = 0;
>>>
>>>      uint8_t cuSize = g_maxCUSize >> depth;
>>>
>>> @@ -345,6 +347,7 @@
>>>      m_sa8dCost         = MAX_INT64;
>>>      m_totalDistortion  = 0;
>>>      m_totalBits        = 0;
>>> +    m_psyCost          = 0;
>>>
>>>      uint8_t cuSize = g_maxCUSize >> depth;
>>>
>>> @@ -393,6 +396,7 @@
>>>      m_sa8dCost         = MAX_INT64;
>>>      m_totalDistortion  = 0;
>>>      m_totalBits        = 0;
>>> +    m_psyCost          = 0;
>>>      m_numPartitions    = cu->getTotalNumPart() >> 2;
>>>
>>>      for (int i = 0; i < 4; i++)
>>> @@ -457,6 +461,7 @@
>>>      m_sa8dCost         = MAX_INT64;
>>>      m_totalDistortion  = 0;
>>>      m_totalBits        = 0;
>>> +    m_psyCost          = 0;
>>>      m_numPartitions    = cu->getTotalNumPart() >> 2;
>>>
>>>      for (int i = 0; i < 4; i++)
>>> @@ -520,6 +525,7 @@
>>>      m_sa8dCost         = MAX_INT64;
>>>      m_totalDistortion  = 0;
>>>      m_totalBits        = 0;
>>> +    m_psyCost          = 0;
>>>      m_numPartitions    = cu->getTotalNumPart() >> 2;
>>>
>>>      TComDataCU* rpcCU = m_pic->getCU(m_cuAddr);
>>> @@ -550,6 +556,7 @@
>>>
>>>      m_totalDistortion  += cu->m_totalDistortion;
>>>      m_totalBits        += cu->m_totalBits;
>>> +    m_psyCost          += cu->m_psyCost;
>>>
>>>      uint32_t offset       = cu->getTotalNumPart() * partUnitIdx;
>>>      uint32_t numPartition = cu->getTotalNumPart();
>>> @@ -610,6 +617,7 @@
>>>      rpcCU->m_totalCost       = m_totalCost;
>>>      rpcCU->m_totalDistortion = m_totalDistortion;
>>>      rpcCU->m_totalBits       = m_totalBits;
>>> +    rpcCU->m_psyCost         = m_psyCost;
>>>
>>>      int sizeInBool  = sizeof(bool) * m_numPartitions;
>>>      int sizeInChar  = sizeof(char) * m_numPartitions;
>>> @@ -695,6 +703,7 @@
>>>      cu->m_totalCost       = m_totalCost;
>>>      cu->m_totalDistortion = m_totalDistortion;
>>>      cu->m_totalBits       = m_totalBits;
>>> +    cu->m_psyCost         = m_psyCost;
>>>
>>>      int sizeInBool  = sizeof(bool) * qNumPart;
>>>      int sizeInChar  = sizeof(char) * qNumPart;
>>> diff -r 5134e76aa729 -r cbe5cc0e48b4 source/Lib/TLibCommon/TComDataCU.h
>>> --- a/source/Lib/TLibCommon/TComDataCU.h        Thu May 22 21:46:21 2014
>>> -0500
>>> +++ b/source/Lib/TLibCommon/TComDataCU.h        Mon May 26 12:29:25 2014
>>> +0530
>>> @@ -168,6 +168,7 @@
>>>      uint64_t      m_totalCost;       ///< sum of partition RD costs
>>>      uint32_t      m_totalDistortion; ///< sum of partition distortion
>>>      uint32_t      m_totalBits;       ///< sum of partition signal bits
>>> +    uint32_t      m_psyCost;
>>>      uint64_t      m_avgCost[4];      // stores the avg cost of CU's in
>>> frame for each depth
>>>      uint32_t      m_count[4];
>>>      uint64_t      m_sa8dCost;
>>> diff -r 5134e76aa729 -r cbe5cc0e48b4 source/Lib/TLibEncoder/TEncCu.cpp
>>> --- a/source/Lib/TLibEncoder/TEncCu.cpp Thu May 22 21:46:21 2014 -0500
>>> +++ b/source/Lib/TLibEncoder/TEncCu.cpp Mon May 26 12:29:25 2014 +0530
>>> @@ -601,7 +601,14 @@
>>>          m_entropyCoder->resetBits();
>>>          m_entropyCoder->encodeSplitFlag(outBestCU, 0, depth);
>>>          outBestCU->m_totalBits +=
>>> m_entropyCoder->getNumberOfWrittenBits(); // split bits
>>> -        outBestCU->m_totalCost  =
>>> m_rdCost->calcRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits);
>>> +        if (m_rdCost->psyRdEnabled())
>>> +        {
>>> +            outBestCU->m_totalCost =
>>> m_rdCost->calcPsyRdCost(outBestCU->m_totalDistortion,
>>> outBestCU->m_totalBits, outBestCU->m_psyCost);
>>>
>>
>> If our objective is to catch unintended comparisons between psyCost and
>> regular RD cost, you should save the above cost (with psyRd enabled) into
>> m_psyCost.
>>
> psyCost is the difference in energy between src and recon and it is
> calculated for each mode when psyrd is enabled
> psyRdCost is calculated from dist, bits and psycost. In this place, it has
> tobe calculated again for the new "bits" with already calculated distortion
> and psycost for best mode.
>
>>
>> +        }
>>> +        else
>>> +        {
>>> +            outBestCU->m_totalCost =
>>> m_rdCost->calcRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits);
>>> +        }
>>>      }
>>>
>>>      outTempCU->initEstData(depth);
>>> @@ -648,7 +655,14 @@
>>>              m_entropyCoder->encodeSplitFlag(outTempCU, 0, depth);
>>>              outTempCU->m_totalBits +=
>>> m_entropyCoder->getNumberOfWrittenBits(); // split bits
>>>          }
>>> -        outTempCU->m_totalCost =
>>> m_rdCost->calcRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);
>>> +        if (m_rdCost->psyRdEnabled())
>>> +        {
>>> +            outTempCU->m_totalCost =
>>> m_rdCost->calcPsyRdCost(outTempCU->m_totalDistortion,
>>> outTempCU->m_totalBits, outTempCU->m_psyCost);
>>> +        }
>>> +        else
>>> +        {
>>> +            outTempCU->m_totalCost =
>>> m_rdCost->calcRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);
>>> +        }
>>>
>>>          if ((g_maxCUSize >> depth) ==
>>> slice->getPPS()->getMinCuDQPSize() && slice->getPPS()->getUseDQP())
>>>          {
>>> @@ -923,7 +937,14 @@
>>>          m_entropyCoder->resetBits();
>>>          m_entropyCoder->encodeSplitFlag(outBestCU, 0, depth);
>>>          outBestCU->m_totalBits +=
>>> m_entropyCoder->getNumberOfWrittenBits(); // split bits
>>> -        outBestCU->m_totalCost  =
>>> m_rdCost->calcRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits);
>>> +        if (m_rdCost->psyRdEnabled())
>>> +        {
>>> +             outBestCU->m_totalCost =
>>> m_rdCost->calcPsyRdCost(outBestCU->m_totalDistortion,
>>> outBestCU->m_totalBits, outBestCU->m_psyCost);
>>> +        }
>>> +        else
>>> +        {
>>> +            outBestCU->m_totalCost =
>>> m_rdCost->calcRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits);
>>> +        }
>>>
>>>          // Early CU determination
>>>          if (outBestCU->isSkipped(0))
>>> @@ -982,7 +1003,14 @@
>>>              m_entropyCoder->encodeSplitFlag(outTempCU, 0, depth);
>>>              outTempCU->m_totalBits +=
>>> m_entropyCoder->getNumberOfWrittenBits(); // split bits
>>>          }
>>> -        outTempCU->m_totalCost =
>>> m_rdCost->calcRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);
>>> +        if(m_rdCost->psyRdEnabled())
>>> +        {
>>> +            outTempCU->m_totalCost =
>>> m_rdCost->calcPsyRdCost(outTempCU->m_totalDistortion,
>>> outTempCU->m_totalBits, outTempCU->m_psyCost);
>>> +        }
>>> +        else
>>> +        {
>>> +            outTempCU->m_totalCost =
>>> m_rdCost->calcRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);
>>> +        }
>>>
>>>          if ((g_maxCUSize >> depth) ==
>>> slice->getPPS()->getMinCuDQPSize() && slice->getPPS()->getUseDQP())
>>>          {
>>> @@ -1391,6 +1419,7 @@
>>>          int part = g_convertToBit[outTempCU->getCUSize(0)];
>>>          uint32_t psyRdCost = m_rdCost->psyCost(part,
>>> m_origYuv[depth]->getLumaAddr(), m_origYuv[depth]->getStride(),
>>>
>>> m_tmpRecoYuv[depth]->getLumaAddr(), m_tmpRecoYuv[depth]->getStride());
>>> +        outTempCU->m_psyCost = psyRdCost;
>>>          outTempCU->m_totalCost =
>>> m_rdCost->calcPsyRdCost(outTempCU->m_totalDistortion,
>>> outTempCU->m_totalBits, psyRdCost);
>>>      }
>>>      else
>>> @@ -1438,6 +1467,7 @@
>>>          int part = g_convertToBit[outTempCU->getCUSize(0)];
>>>          uint32_t psyRdCost = m_rdCost->psyCost(part,
>>> m_origYuv[depth]->getLumaAddr(), m_origYuv[depth]->getStride(),
>>>
>>> m_tmpRecoYuv[depth]->getLumaAddr(), m_tmpRecoYuv[depth]->getStride());
>>> +        outTempCU->m_psyCost = psyRdCost;
>>>          outTempCU->m_totalCost =
>>> m_rdCost->calcPsyRdCost(outTempCU->m_totalDistortion,
>>> outTempCU->m_totalBits, psyRdCost);
>>>      }
>>>      else
>>> diff -r 5134e76aa729 -r cbe5cc0e48b4
>>> source/Lib/TLibEncoder/TEncSearch.cpp
>>> --- a/source/Lib/TLibEncoder/TEncSearch.cpp     Thu May 22 21:46:21 2014
>>> -0500
>>> +++ b/source/Lib/TLibEncoder/TEncSearch.cpp     Mon May 26 12:29:25 2014
>>> +0530
>>> @@ -2698,6 +2698,7 @@
>>>              int size = g_convertToBit[cu->getCUSize(0)];
>>>              uint32_t psyRdCost = m_rdCost->psyCost(size,
>>> fencYuv->getLumaAddr(), fencYuv->getStride(),
>>>
>>> outReconYuv->getLumaAddr(), outReconYuv->getStride());
>>> +            cu->m_psyCost = psyRdCost;
>>>              cu->m_totalCost =
>>> m_rdCost->calcPsyRdCost(cu->m_totalDistortion, cu->m_totalBits, psyRdCost);
>>>          }
>>>          else
>>> @@ -2789,6 +2790,7 @@
>>>          int size = g_convertToBit[cu->getCUSize(0)];
>>>          uint32_t psyRdCost = m_rdCost->psyCost(size,
>>> fencYuv->getLumaAddr(), fencYuv->getStride(),
>>>
>>> outReconYuv->getLumaAddr(), outReconYuv->getStride());
>>> +        cu->m_psyCost = psyRdCost;
>>>          bcost = m_rdCost->calcPsyRdCost(bdist, bestBits, psyRdCost);
>>>      }
>>>      else
>>> _______________________________________________
>>> x265-devel mailing list
>>> x265-devel at videolan.org
>>> https://mailman.videolan.org/listinfo/x265-devel
>>>
>>
>>
>> _______________________________________________
>> x265-devel mailing list
>> x265-devel at videolan.org
>> https://mailman.videolan.org/listinfo/x265-devel
>>
>>
>
> _______________________________________________
> 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/20140526/b04bb1f4/attachment-0001.html>


More information about the x265-devel mailing list