[x265] [PATCH] move statistics calculation to csv-log-level

Pradeep Ramachandran pradeep at multicorewareinc.com
Fri Jun 23 05:46:40 CEST 2017


On Thu, Jun 22, 2017 at 3:35 PM, <bhavna at multicorewareinc.com> wrote:

> # HG changeset patch
> # User Bhavna Hariharan <bhavna at multicorewareinc.com>
> # Date 1498114175 -19800
> #      Thu Jun 22 12:19:35 2017 +0530
> # Node ID 69f316d001b5c1b16e4e2f42442c27a12754bcde
> # Parent  586d06ad195ae6907282e8a9048770145c0bd437
> move statistics calculation to csv-log-level
>

Pushed to default branch


>
> diff -r 586d06ad195a -r 69f316d001b5 source/common/picyuv.cpp
> --- a/source/common/picyuv.cpp  Wed Jun 21 10:03:53 2017 +0530
> +++ b/source/common/picyuv.cpp  Thu Jun 22 12:19:35 2017 +0530
> @@ -340,7 +340,7 @@
>      pixel *U = m_picOrg[1];
>      pixel *V = m_picOrg[2];
>
> -    if (param.logLevel >= 2)
> +    if (param.csvLogLevel >= 2)
>      {
>          pixel *yPic = m_picOrg[0];
>          pixel *uPic = m_picOrg[1];
> diff -r 586d06ad195a -r 69f316d001b5 source/encoder/analysis.cpp
> --- a/source/encoder/analysis.cpp       Wed Jun 21 10:03:53 2017 +0530
> +++ b/source/encoder/analysis.cpp       Thu Jun 22 12:19:35 2017 +0530
> @@ -281,7 +281,7 @@
>      if (m_param->bEnableRdRefine || m_param->bOptCUDeltaQP)
>          qprdRefine(ctu, cuGeom, qp, qp);
>
> -    if (m_param->logLevel >= 2)
> +    if (m_param->csvLogLevel >= 2)
>          collectPUStatistics(ctu, cuGeom);
>
>      return *m_modeDepth[0].bestMode;
> diff -r 586d06ad195a -r 69f316d001b5 source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp        Wed Jun 21 10:03:53 2017 +0530
> +++ b/source/encoder/encoder.cpp        Thu Jun 22 12:19:35 2017 +0530
> @@ -1709,7 +1709,8 @@
>          frameStats->qp = curEncData.m_avgQpAq;
>          frameStats->bits = bits;
>          frameStats->bScenecut = curFrame->m_lowres.bScenecut;
> -        frameStats->ipCostRatio = curFrame->m_lowres.ipCostRatio;
> +        if (m_param->csvLogLevel >= 2)
> +            frameStats->ipCostRatio = curFrame->m_lowres.ipCostRatio;
>          frameStats->bufferFill = m_rateControl->m_bufferFillActual;
>          frameStats->frameLatency = inPoc - poc;
>          if (m_param->rc.rateControlMode == X265_RC_CRF)
> @@ -1734,74 +1735,81 @@
>
>  #define ELAPSED_MSEC(start, end) (((double)(end) - (start)) / 1000)
>
> -        frameStats->decideWaitTime = ELAPSED_MSEC(0, curEncoder->m_
> slicetypeWaitTime);
> -        frameStats->row0WaitTime = ELAPSED_MSEC(curEncoder->m_startCompressTime,
> curEncoder->m_row0WaitTime);
> -        frameStats->wallTime = ELAPSED_MSEC(curEncoder->m_row0WaitTime,
> curEncoder->m_endCompressTime);
> -        frameStats->refWaitWallTime = ELAPSED_MSEC(curEncoder->m_row0WaitTime,
> curEncoder->m_allRowsAvailableTime);
> -        frameStats->totalCTUTime = ELAPSED_MSEC(0, curEncoder->m_
> totalWorkerElapsedTime);
> -        frameStats->stallTime = ELAPSED_MSEC(0, curEncoder->m_
> totalNoWorkerTime);
> -        frameStats->totalFrameTime = ELAPSED_MSEC(curFrame->m_encodeStartTime,
> x265_mdate());
> -        if (curEncoder->m_totalActiveWorkerCount)
> -            frameStats->avgWPP = (double)curEncoder->m_totalActiveWorkerCount
> / curEncoder->m_activeWorkerCountSamples;
> -        else
> -            frameStats->avgWPP = 1;
> -        frameStats->countRowBlocks = curEncoder->m_countRowBlocks;
> -
> -        frameStats->cuStats.percentIntraNxN = curFrame->m_encData->m_
> frameStats.percentIntraNxN;
> -        frameStats->avgChromaDistortion     = curFrame->m_encData->m_
> frameStats.avgChromaDistortion;
> -        frameStats->avgLumaDistortion       = curFrame->m_encData->m_
> frameStats.avgLumaDistortion;
> -        frameStats->avgPsyEnergy            = curFrame->m_encData->m_
> frameStats.avgPsyEnergy;
> -        frameStats->avgResEnergy            = curFrame->m_encData->m_
> frameStats.avgResEnergy;
> -        frameStats->avgLumaLevel            = curFrame->m_fencPic->m_
> avgLumaLevel;
> -        frameStats->maxLumaLevel            = curFrame->m_fencPic->m_
> maxLumaLevel;
> -        frameStats->minLumaLevel            = curFrame->m_fencPic->m_
> minLumaLevel;
> -
> -        frameStats->maxChromaULevel = curFrame->m_fencPic->m_
> maxChromaULevel;
> -        frameStats->minChromaULevel = curFrame->m_fencPic->m_
> minChromaULevel;
> -        frameStats->avgChromaULevel = curFrame->m_fencPic->m_
> avgChromaULevel;
> -
> -        frameStats->maxChromaVLevel = curFrame->m_fencPic->m_
> maxChromaVLevel;
> -        frameStats->minChromaVLevel = curFrame->m_fencPic->m_
> minChromaVLevel;
> -        frameStats->avgChromaVLevel = curFrame->m_fencPic->m_
> avgChromaVLevel;
> -
> -        for (uint32_t depth = 0; depth <= m_param->maxCUDepth; depth++)
> +        if (m_param->csvLogLevel >= 2)
>          {
> -            frameStats->cuStats.percentSkipCu[depth]  =
> curFrame->m_encData->m_frameStats.percentSkipCu[depth];
> -            frameStats->cuStats.percentMergeCu[depth] =
> curFrame->m_encData->m_frameStats.percentMergeCu[depth];
> -            frameStats->cuStats.percentInterDistribution[depth][0] =
> curFrame->m_encData->m_frameStats.percentInterDistribution[depth][0];
> -            frameStats->cuStats.percentInterDistribution[depth][1] =
> curFrame->m_encData->m_frameStats.percentInterDistribution[depth][1];
> -            frameStats->cuStats.percentInterDistribution[depth][2] =
> curFrame->m_encData->m_frameStats.percentInterDistribution[depth][2];
> -            for (int n = 0; n < INTRA_MODES; n++)
> -                frameStats->cuStats.percentIntraDistribution[depth][n] =
> curFrame->m_encData->m_frameStats.percentIntraDistribution[depth][n];
> -        }
> -
> -        if (curFrame->m_encData->m_frameStats.totalPu[4] == 0)
> -            frameStats->puStats.percentNxN = 0;
> -        else
> -            frameStats->puStats.percentNxN =
> (double)(curFrame->m_encData->m_frameStats.cnt4x4 /
> (double)curFrame->m_encData->m_frameStats.totalPu[4]) * 100;
> -        for (uint32_t depth = 0; depth <= m_param->maxCUDepth; depth++)
> -        {
> -            if (curFrame->m_encData->m_frameStats.totalPu[depth] == 0)
> +            frameStats->decideWaitTime = ELAPSED_MSEC(0, curEncoder->m_
> slicetypeWaitTime);
> +            frameStats->row0WaitTime = ELAPSED_MSEC(curEncoder->m_startCompressTime,
> curEncoder->m_row0WaitTime);
> +            frameStats->wallTime = ELAPSED_MSEC(curEncoder->m_row0WaitTime,
> curEncoder->m_endCompressTime);
> +            frameStats->refWaitWallTime = ELAPSED_MSEC(curEncoder->m_row0WaitTime,
> curEncoder->m_allRowsAvailableTime);
> +            frameStats->totalCTUTime = ELAPSED_MSEC(0, curEncoder->m_
> totalWorkerElapsedTime);
> +            frameStats->stallTime = ELAPSED_MSEC(0, curEncoder->m_
> totalNoWorkerTime);
> +            frameStats->totalFrameTime = ELAPSED_MSEC(curFrame->m_encodeStartTime,
> x265_mdate());
> +            if (curEncoder->m_totalActiveWorkerCount)
> +                frameStats->avgWPP = (double)curEncoder->m_totalActiveWorkerCount
> / curEncoder->m_activeWorkerCountSamples;
> +            else
> +                frameStats->avgWPP = 1;
> +            frameStats->countRowBlocks = curEncoder->m_countRowBlocks;
> +
> +            frameStats->avgChromaDistortion = curFrame->m_encData->m_
> frameStats.avgChromaDistortion;
> +            frameStats->avgLumaDistortion = curFrame->m_encData->m_
> frameStats.avgLumaDistortion;
> +            frameStats->avgPsyEnergy = curFrame->m_encData->m_
> frameStats.avgPsyEnergy;
> +            frameStats->avgResEnergy = curFrame->m_encData->m_
> frameStats.avgResEnergy;
> +            frameStats->avgLumaLevel = curFrame->m_fencPic->m_
> avgLumaLevel;
> +            frameStats->maxLumaLevel = curFrame->m_fencPic->m_
> maxLumaLevel;
> +            frameStats->minLumaLevel = curFrame->m_fencPic->m_
> minLumaLevel;
> +
> +            frameStats->maxChromaULevel = curFrame->m_fencPic->m_
> maxChromaULevel;
> +            frameStats->minChromaULevel = curFrame->m_fencPic->m_
> minChromaULevel;
> +            frameStats->avgChromaULevel = curFrame->m_fencPic->m_
> avgChromaULevel;
> +
> +            frameStats->maxChromaVLevel = curFrame->m_fencPic->m_
> maxChromaVLevel;
> +            frameStats->minChromaVLevel = curFrame->m_fencPic->m_
> minChromaVLevel;
> +            frameStats->avgChromaVLevel = curFrame->m_fencPic->m_
> avgChromaVLevel;
> +
> +            if (curFrame->m_encData->m_frameStats.totalPu[4] == 0)
> +                frameStats->puStats.percentNxN = 0;
> +            else
> +                frameStats->puStats.percentNxN =
> (double)(curFrame->m_encData->m_frameStats.cnt4x4 /
> (double)curFrame->m_encData->m_frameStats.totalPu[4]) * 100;
> +            for (uint32_t depth = 0; depth <= m_param->maxCUDepth;
> depth++)
>              {
> -                frameStats->puStats.percentSkipPu[depth] = 0;
> -                frameStats->puStats.percentIntraPu[depth] = 0;
> -                frameStats->puStats.percentAmpPu[depth] = 0;
> -                for (int i = 0; i < INTER_MODES - 1; i++)
> +                if (curFrame->m_encData->m_frameStats.totalPu[depth] ==
> 0)
>                  {
> -                    frameStats->puStats.percentInterPu[depth][i] = 0;
> -                    frameStats->puStats.percentMergePu[depth][i] = 0;
> +                    frameStats->puStats.percentSkipPu[depth] = 0;
> +                    frameStats->puStats.percentIntraPu[depth] = 0;
> +                    frameStats->puStats.percentAmpPu[depth] = 0;
> +                    for (int i = 0; i < INTER_MODES - 1; i++)
> +                    {
> +                        frameStats->puStats.percentInterPu[depth][i] = 0;
> +                        frameStats->puStats.percentMergePu[depth][i] = 0;
> +                    }
> +                }
> +                else
> +                {
> +                    frameStats->puStats.percentSkipPu[depth] =
> (double)(curFrame->m_encData->m_frameStats.cntSkipPu[depth] /
> (double)curFrame->m_encData->m_frameStats.totalPu[depth]) * 100;
> +                    frameStats->puStats.percentIntraPu[depth] =
> (double)(curFrame->m_encData->m_frameStats.cntIntraPu[depth] /
> (double)curFrame->m_encData->m_frameStats.totalPu[depth]) * 100;
> +                    frameStats->puStats.percentAmpPu[depth] =
> (double)(curFrame->m_encData->m_frameStats.cntAmp[depth] /
> (double)curFrame->m_encData->m_frameStats.totalPu[depth]) * 100;
> +                    for (int i = 0; i < INTER_MODES - 1; i++)
> +                    {
> +                        frameStats->puStats.percentInterPu[depth][i] =
> (double)(curFrame->m_encData->m_frameStats.cntInterPu[depth][i] /
> (double)curFrame->m_encData->m_frameStats.totalPu[depth]) * 100;
> +                        frameStats->puStats.percentMergePu[depth][i] =
> (double)(curFrame->m_encData->m_frameStats.cntMergePu[depth][i] /
> (double)curFrame->m_encData->m_frameStats.totalPu[depth]) * 100;
> +                    }
>                  }
>              }
> -            else
> +        }
> +
> +        if (m_param->csvLogLevel >= 1)
> +        {
> +            frameStats->cuStats.percentIntraNxN = curFrame->m_encData->m_
> frameStats.percentIntraNxN;
> +
> +            for (uint32_t depth = 0; depth <= m_param->maxCUDepth;
> depth++)
>              {
> -                frameStats->puStats.percentSkipPu[depth] =
> (double)(curFrame->m_encData->m_frameStats.cntSkipPu[depth] /
> (double)curFrame->m_encData->m_frameStats.totalPu[depth]) * 100;
> -                frameStats->puStats.percentIntraPu[depth] =
> (double)(curFrame->m_encData->m_frameStats.cntIntraPu[depth] /
> (double)curFrame->m_encData->m_frameStats.totalPu[depth]) * 100;
> -                frameStats->puStats.percentAmpPu[depth] =
> (double)(curFrame->m_encData->m_frameStats.cntAmp[depth] /
> (double)curFrame->m_encData->m_frameStats.totalPu[depth]) * 100;
> -                for (int i = 0; i < INTER_MODES - 1; i++)
> -                {
> -                    frameStats->puStats.percentInterPu[depth][i] =
> (double)(curFrame->m_encData->m_frameStats.cntInterPu[depth][i] /
> (double)curFrame->m_encData->m_frameStats.totalPu[depth]) * 100;
> -                    frameStats->puStats.percentMergePu[depth][i] =
> (double)(curFrame->m_encData->m_frameStats.cntMergePu[depth][i] /
> (double)curFrame->m_encData->m_frameStats.totalPu[depth]) * 100;
> -                }
> +                frameStats->cuStats.percentSkipCu[depth] =
> curFrame->m_encData->m_frameStats.percentSkipCu[depth];
> +                frameStats->cuStats.percentMergeCu[depth] =
> curFrame->m_encData->m_frameStats.percentMergeCu[depth];
> +                frameStats->cuStats.percentInterDistribution[depth][0] =
> curFrame->m_encData->m_frameStats.percentInterDistribution[depth][0];
> +                frameStats->cuStats.percentInterDistribution[depth][1] =
> curFrame->m_encData->m_frameStats.percentInterDistribution[depth][1];
> +                frameStats->cuStats.percentInterDistribution[depth][2] =
> curFrame->m_encData->m_frameStats.percentInterDistribution[depth][2];
> +                for (int n = 0; n < INTRA_MODES; n++)
> +                    frameStats->cuStats.percentIntraDistribution[depth][n]
> = curFrame->m_encData->m_frameStats.percentIntraDistribution[depth][n];
>              }
>          }
>      }
> diff -r 586d06ad195a -r 69f316d001b5 source/encoder/frameencoder.cpp
> --- a/source/encoder/frameencoder.cpp   Wed Jun 21 10:03:53 2017 +0530
> +++ b/source/encoder/frameencoder.cpp   Thu Jun 22 12:19:35 2017 +0530
> @@ -877,43 +877,52 @@
>          m_frame->m_encData->m_frameStats.percent8x8Inter =
> (double)totalP / totalCuCount;
>          m_frame->m_encData->m_frameStats.percent8x8Skip  =
> (double)totalSkip / totalCuCount;
>      }
> -    for (uint32_t i = 0; i < m_numRows; i++)
> +
> +    if (m_param->csvLogLevel >= 1)
>      {
> -        m_frame->m_encData->m_frameStats.cntIntraNxN      +=
> m_rows[i].rowStats.cntIntraNxN;
> -        m_frame->m_encData->m_frameStats.totalCu          +=
> m_rows[i].rowStats.totalCu;
> -        m_frame->m_encData->m_frameStats.totalCtu         +=
> m_rows[i].rowStats.totalCtu;
> -        m_frame->m_encData->m_frameStats.lumaDistortion   +=
> m_rows[i].rowStats.lumaDistortion;
> -        m_frame->m_encData->m_frameStats.chromaDistortion +=
> m_rows[i].rowStats.chromaDistortion;
> -        m_frame->m_encData->m_frameStats.psyEnergy        +=
> m_rows[i].rowStats.psyEnergy;
> -        m_frame->m_encData->m_frameStats.ssimEnergy       +=
> m_rows[i].rowStats.ssimEnergy;
> -        m_frame->m_encData->m_frameStats.resEnergy        +=
> m_rows[i].rowStats.resEnergy;
> +        for (uint32_t i = 0; i < m_numRows; i++)
> +        {
> +            m_frame->m_encData->m_frameStats.cntIntraNxN +=
> m_rows[i].rowStats.cntIntraNxN;
> +            m_frame->m_encData->m_frameStats.totalCu +=
> m_rows[i].rowStats.totalCu;
> +            m_frame->m_encData->m_frameStats.totalCtu +=
> m_rows[i].rowStats.totalCtu;
> +            m_frame->m_encData->m_frameStats.lumaDistortion +=
> m_rows[i].rowStats.lumaDistortion;
> +            m_frame->m_encData->m_frameStats.chromaDistortion +=
> m_rows[i].rowStats.chromaDistortion;
> +            m_frame->m_encData->m_frameStats.psyEnergy +=
> m_rows[i].rowStats.psyEnergy;
> +            m_frame->m_encData->m_frameStats.ssimEnergy +=
> m_rows[i].rowStats.ssimEnergy;
> +            m_frame->m_encData->m_frameStats.resEnergy +=
> m_rows[i].rowStats.resEnergy;
> +            for (uint32_t depth = 0; depth <= m_param->maxCUDepth;
> depth++)
> +            {
> +                m_frame->m_encData->m_frameStats.cntSkipCu[depth] +=
> m_rows[i].rowStats.cntSkipCu[depth];
> +                m_frame->m_encData->m_frameStats.cntMergeCu[depth] +=
> m_rows[i].rowStats.cntMergeCu[depth];
> +                for (int m = 0; m < INTER_MODES; m++)
> +                    m_frame->m_encData->m_frameStats.cuInterDistribution[depth][m]
> += m_rows[i].rowStats.cuInterDistribution[depth][m];
> +                for (int n = 0; n < INTRA_MODES; n++)
> +                    m_frame->m_encData->m_frameStats.cuIntraDistribution[depth][n]
> += m_rows[i].rowStats.cuIntraDistribution[depth][n];
> +            }
> +        }
> +        m_frame->m_encData->m_frameStats.percentIntraNxN =
> (double)(m_frame->m_encData->m_frameStats.cntIntraNxN * 100) /
> m_frame->m_encData->m_frameStats.totalCu;
> +
>          for (uint32_t depth = 0; depth <= m_param->maxCUDepth; depth++)
>          {
> -            m_frame->m_encData->m_frameStats.cntSkipCu[depth] +=
> m_rows[i].rowStats.cntSkipCu[depth];
> -            m_frame->m_encData->m_frameStats.cntMergeCu[depth] +=
> m_rows[i].rowStats.cntMergeCu[depth];
> -            for (int m = 0; m < INTER_MODES; m++)
> -                m_frame->m_encData->m_frameStats.cuInterDistribution[depth][m]
> += m_rows[i].rowStats.cuInterDistribution[depth][m];
> +            m_frame->m_encData->m_frameStats.percentSkipCu[depth] =
> (double)(m_frame->m_encData->m_frameStats.cntSkipCu[depth] * 100) /
> m_frame->m_encData->m_frameStats.totalCu;
> +            m_frame->m_encData->m_frameStats.percentMergeCu[depth] =
> (double)(m_frame->m_encData->m_frameStats.cntMergeCu[depth] * 100) /
> m_frame->m_encData->m_frameStats.totalCu;
>              for (int n = 0; n < INTRA_MODES; n++)
> -                m_frame->m_encData->m_frameStats.cuIntraDistribution[depth][n]
> += m_rows[i].rowStats.cuIntraDistribution[depth][n];
> +                m_frame->m_encData->m_frameStats.
> percentIntraDistribution[depth][n] = (double)(m_frame->m_encData->
> m_frameStats.cuIntraDistribution[depth][n] * 100) / m_frame->m_encData->m_
> frameStats.totalCu;
> +            uint64_t cuInterRectCnt = 0; // sum of Nx2N, 2NxN counts
> +            cuInterRectCnt += m_frame->m_encData->m_frameStats.cuInterDistribution[depth][1]
> + m_frame->m_encData->m_frameStats.cuInterDistribution[depth][2];
> +            m_frame->m_encData->m_frameStats.percentInterDistribution[depth][0]
> = (double)(m_frame->m_encData->m_frameStats.cuInterDistribution[depth][0]
> * 100) / m_frame->m_encData->m_frameStats.totalCu;
> +            m_frame->m_encData->m_frameStats.percentInterDistribution[depth][1]
> = (double)(cuInterRectCnt * 100) / m_frame->m_encData->m_
> frameStats.totalCu;
> +            m_frame->m_encData->m_frameStats.percentInterDistribution[depth][2]
> = (double)(m_frame->m_encData->m_frameStats.cuInterDistribution[depth][3]
> * 100) / m_frame->m_encData->m_frameStats.totalCu;
>          }
>      }
> -    m_frame->m_encData->m_frameStats.avgLumaDistortion   =
> (double)(m_frame->m_encData->m_frameStats.lumaDistortion) /
> m_frame->m_encData->m_frameStats.totalCtu;
> -    m_frame->m_encData->m_frameStats.avgChromaDistortion =
> (double)(m_frame->m_encData->m_frameStats.chromaDistortion) /
> m_frame->m_encData->m_frameStats.totalCtu;
> -    m_frame->m_encData->m_frameStats.avgPsyEnergy        =
> (double)(m_frame->m_encData->m_frameStats.psyEnergy) /
> m_frame->m_encData->m_frameStats.totalCtu;
> -    m_frame->m_encData->m_frameStats.avgSsimEnergy       =
> (double)(m_frame->m_encData->m_frameStats.ssimEnergy) /
> m_frame->m_encData->m_frameStats.totalCtu;
> -    m_frame->m_encData->m_frameStats.avgResEnergy        =
> (double)(m_frame->m_encData->m_frameStats.resEnergy) /
> m_frame->m_encData->m_frameStats.totalCtu;
> -    m_frame->m_encData->m_frameStats.percentIntraNxN     =
> (double)(m_frame->m_encData->m_frameStats.cntIntraNxN * 100) /
> m_frame->m_encData->m_frameStats.totalCu;
> -    for (uint32_t depth = 0; depth <= m_param->maxCUDepth; depth++)
> +
> +    if (m_param->csvLogLevel >= 2)
>      {
> -        m_frame->m_encData->m_frameStats.percentSkipCu[depth]  =
> (double)(m_frame->m_encData->m_frameStats.cntSkipCu[depth] * 100) /
> m_frame->m_encData->m_frameStats.totalCu;
> -        m_frame->m_encData->m_frameStats.percentMergeCu[depth] =
> (double)(m_frame->m_encData->m_frameStats.cntMergeCu[depth] * 100) /
> m_frame->m_encData->m_frameStats.totalCu;
> -        for (int n = 0; n < INTRA_MODES; n++)
> -            m_frame->m_encData->m_frameStats.percentIntraDistribution[depth][n]
> = (double)(m_frame->m_encData->m_frameStats.cuIntraDistribution[depth][n]
> * 100) / m_frame->m_encData->m_frameStats.totalCu;
> -        uint64_t cuInterRectCnt = 0; // sum of Nx2N, 2NxN counts
> -        cuInterRectCnt += m_frame->m_encData->m_frameStats.cuInterDistribution[depth][1]
> + m_frame->m_encData->m_frameStats.cuInterDistribution[depth][2];
> -        m_frame->m_encData->m_frameStats.percentInterDistribution[depth][0]
> = (double)(m_frame->m_encData->m_frameStats.cuInterDistribution[depth][0]
> * 100) / m_frame->m_encData->m_frameStats.totalCu;
> -        m_frame->m_encData->m_frameStats.percentInterDistribution[depth][1]
> = (double)(cuInterRectCnt * 100) / m_frame->m_encData->m_
> frameStats.totalCu;
> -        m_frame->m_encData->m_frameStats.percentInterDistribution[depth][2]
> = (double)(m_frame->m_encData->m_frameStats.cuInterDistribution[depth][3]
> * 100) / m_frame->m_encData->m_frameStats.totalCu;
> +        m_frame->m_encData->m_frameStats.avgLumaDistortion =
> (double)(m_frame->m_encData->m_frameStats.lumaDistortion) /
> m_frame->m_encData->m_frameStats.totalCtu;
> +        m_frame->m_encData->m_frameStats.avgChromaDistortion =
> (double)(m_frame->m_encData->m_frameStats.chromaDistortion) /
> m_frame->m_encData->m_frameStats.totalCtu;
> +        m_frame->m_encData->m_frameStats.avgPsyEnergy =
> (double)(m_frame->m_encData->m_frameStats.psyEnergy) /
> m_frame->m_encData->m_frameStats.totalCtu;
> +        m_frame->m_encData->m_frameStats.avgSsimEnergy =
> (double)(m_frame->m_encData->m_frameStats.ssimEnergy) /
> m_frame->m_encData->m_frameStats.totalCtu;
> +        m_frame->m_encData->m_frameStats.avgResEnergy =
> (double)(m_frame->m_encData->m_frameStats.resEnergy) /
> m_frame->m_encData->m_frameStats.totalCtu;
>      }
>
>      m_bs.resetBits();
> @@ -1744,73 +1753,36 @@
>  int FrameEncoder::collectCTUStatistics(const CUData& ctu, FrameStats*
> log)
>  {
>      int totQP = 0;
> -    if (ctu.m_slice->m_sliceType == I_SLICE)
> +    uint32_t depth = 0;
> +    for (uint32_t absPartIdx = 0; absPartIdx < ctu.m_numPartitions;
> absPartIdx += ctu.m_numPartitions >> (depth * 2))
>      {
> -        uint32_t depth = 0;
> -        for (uint32_t absPartIdx = 0; absPartIdx < ctu.m_numPartitions;
> absPartIdx += ctu.m_numPartitions >> (depth * 2))
> +        depth = ctu.m_cuDepth[absPartIdx];
> +        totQP += ctu.m_qp[absPartIdx] * (ctu.m_numPartitions >> (depth *
> 2));
> +    }
> +
> +    if (m_param->csvLogLevel >= 1)
> +    {
> +        if (ctu.m_slice->m_sliceType == I_SLICE)
>          {
> -            depth = ctu.m_cuDepth[absPartIdx];
> +            depth = 0;
> +            for (uint32_t absPartIdx = 0; absPartIdx <
> ctu.m_numPartitions; absPartIdx += ctu.m_numPartitions >> (depth * 2))
> +            {
> +                depth = ctu.m_cuDepth[absPartIdx];
>
> -            log->totalCu++;
> -            log->cntIntra[depth]++;
> -            totQP += ctu.m_qp[absPartIdx] * (ctu.m_numPartitions >>
> (depth * 2));
> -
> -            if (ctu.m_predMode[absPartIdx] == MODE_NONE)
> -            {
> -                log->totalCu--;
> -                log->cntIntra[depth]--;
> -            }
> -            else if (ctu.m_partSize[absPartIdx] != SIZE_2Nx2N)
> -            {
> -                /* TODO: log intra modes at absPartIdx +0 to +3 */
> -                X265_CHECK(ctu.m_log2CUSize[absPartIdx] == 3 &&
> ctu.m_slice->m_sps->quadtreeTULog2MinSize < 3, "Intra NxN found at
> improbable depth\n");
> -                log->cntIntraNxN++;
> -                log->cntIntra[depth]--;
> -            }
> -            else if (ctu.m_lumaIntraDir[absPartIdx] > 1)
> -                log->cuIntraDistribution[depth][ANGULAR_MODE_ID]++;
> -            else
> -                log->cuIntraDistribution[depth][ctu.m_lumaIntraDir[
> absPartIdx]]++;
> -        }
> -    }
> -    else
> -    {
> -        uint32_t depth = 0;
> -        for (uint32_t absPartIdx = 0; absPartIdx < ctu.m_numPartitions;
> absPartIdx += ctu.m_numPartitions >> (depth * 2))
> -        {
> -            depth = ctu.m_cuDepth[absPartIdx];
> -
> -            log->totalCu++;
> -            totQP += ctu.m_qp[absPartIdx] * (ctu.m_numPartitions >>
> (depth * 2));
> -
> -            if (ctu.m_predMode[absPartIdx] == MODE_NONE)
> -                log->totalCu--;
> -            else if (ctu.isSkipped(absPartIdx))
> -            {
> -                if (ctu.m_mergeFlag[0])
> -                    log->cntMergeCu[depth]++;
> -                else
> -                    log->cntSkipCu[depth]++;
> -            }
> -            else if (ctu.isInter(absPartIdx))
> -            {
> -                log->cntInter[depth]++;
> -
> -                if (ctu.m_partSize[absPartIdx] < AMP_ID)
> -                    log->cuInterDistribution[depth][ctu.m_partSize[
> absPartIdx]]++;
> -                else
> -                    log->cuInterDistribution[depth][AMP_ID]++;
> -            }
> -            else if (ctu.isIntra(absPartIdx))
> -            {
> +                log->totalCu++;
>                  log->cntIntra[depth]++;
>
> -                if (ctu.m_partSize[absPartIdx] != SIZE_2Nx2N)
> +                if (ctu.m_predMode[absPartIdx] == MODE_NONE)
>                  {
> +                    log->totalCu--;
> +                    log->cntIntra[depth]--;
> +                }
> +                else if (ctu.m_partSize[absPartIdx] != SIZE_2Nx2N)
> +                {
> +                    /* TODO: log intra modes at absPartIdx +0 to +3 */
>                      X265_CHECK(ctu.m_log2CUSize[absPartIdx] == 3 &&
> ctu.m_slice->m_sps->quadtreeTULog2MinSize < 3, "Intra NxN found at
> improbable depth\n");
>                      log->cntIntraNxN++;
>                      log->cntIntra[depth]--;
> -                    /* TODO: log intra modes at absPartIdx +0 to +3 */
>                  }
>                  else if (ctu.m_lumaIntraDir[absPartIdx] > 1)
>                      log->cuIntraDistribution[depth][ANGULAR_MODE_ID]++;
> @@ -1818,6 +1790,51 @@
>                      log->cuIntraDistribution[depth][ctu.m_lumaIntraDir[
> absPartIdx]]++;
>              }
>          }
> +        else
> +        {
> +            depth = 0;
> +            for (uint32_t absPartIdx = 0; absPartIdx <
> ctu.m_numPartitions; absPartIdx += ctu.m_numPartitions >> (depth * 2))
> +            {
> +                depth = ctu.m_cuDepth[absPartIdx];
> +
> +                log->totalCu++;
> +
> +                if (ctu.m_predMode[absPartIdx] == MODE_NONE)
> +                    log->totalCu--;
> +                else if (ctu.isSkipped(absPartIdx))
> +                {
> +                    if (ctu.m_mergeFlag[0])
> +                        log->cntMergeCu[depth]++;
> +                    else
> +                        log->cntSkipCu[depth]++;
> +                }
> +                else if (ctu.isInter(absPartIdx))
> +                {
> +                    log->cntInter[depth]++;
> +
> +                    if (ctu.m_partSize[absPartIdx] < AMP_ID)
> +                        log->cuInterDistribution[depth][ctu.m_partSize[
> absPartIdx]]++;
> +                    else
> +                        log->cuInterDistribution[depth][AMP_ID]++;
> +                }
> +                else if (ctu.isIntra(absPartIdx))
> +                {
> +                    log->cntIntra[depth]++;
> +
> +                    if (ctu.m_partSize[absPartIdx] != SIZE_2Nx2N)
> +                    {
> +                        X265_CHECK(ctu.m_log2CUSize[absPartIdx] == 3 &&
> ctu.m_slice->m_sps->quadtreeTULog2MinSize < 3, "Intra NxN found at
> improbable depth\n");
> +                        log->cntIntraNxN++;
> +                        log->cntIntra[depth]--;
> +                        /* TODO: log intra modes at absPartIdx +0 to +3 */
> +                    }
> +                    else if (ctu.m_lumaIntraDir[absPartIdx] > 1)
> +                        log->cuIntraDistribution[
> depth][ANGULAR_MODE_ID]++;
> +                    else
> +                        log->cuIntraDistribution[
> depth][ctu.m_lumaIntraDir[absPartIdx]]++;
> +                }
> +            }
> +        }
>      }
>
>      return totQP;
> diff -r 586d06ad195a -r 69f316d001b5 source/encoder/slicetype.cpp
> --- a/source/encoder/slicetype.cpp      Wed Jun 21 10:03:53 2017 +0530
> +++ b/source/encoder/slicetype.cpp      Thu Jun 22 12:19:35 2017 +0530
> @@ -1638,7 +1638,7 @@
>              m_isSceneTransition = false; /* Signal end of scene
> transitioning */
>      }
>
> -    if (m_param->logLevel >= 2)
> +    if (m_param->csvLogLevel >= 2)
>      {
>          int64_t icost = frames[p1]->costEst[0][0];
>          int64_t pcost = frames[p1]->costEst[p1 - p0][0];
> diff -r 586d06ad195a -r 69f316d001b5 source/x265-extras.cpp
> --- a/source/x265-extras.cpp    Wed Jun 21 10:03:53 2017 +0530
> +++ b/source/x265-extras.cpp    Thu Jun 22 12:19:35 2017 +0530
> @@ -106,14 +106,15 @@
>                      fprintf(csvfp, ", Merge %dx%d", size, size);
>                      size /= 2;
>                  }
> -                fprintf(csvfp, ", Avg Luma Distortion, Avg Chroma
> Distortion, Avg psyEnergy, Avg Residual Energy,"
> -                               " Min Luma Level, Max Luma Level, Avg Luma
> Level");
> -
> -                if (param.internalCsp != X265_CSP_I400)
> -                    fprintf(csvfp, ", Min Cb Level, Max Cb Level, Avg Cb
> Level, Min Cr Level, Max Cr Level, Avg Cr Level");
>
>                  if (level >= 2)
>                  {
> +                    fprintf(csvfp, ", Avg Luma Distortion, Avg Chroma
> Distortion, Avg psyEnergy, Avg Residual Energy,"
> +                        " Min Luma Level, Max Luma Level, Avg Luma
> Level");
> +
> +                    if (param.internalCsp != X265_CSP_I400)
> +                        fprintf(csvfp, ", Min Cb Level, Max Cb Level, Avg
> Cb Level, Min Cr Level, Max Cr Level, Avg Cr Level");
> +
>                      /* PU statistics */
>                      size = param.maxCUSize;
>                      for (uint32_t i = 0; i< param.maxLog2CUSize -
> (uint32_t)g_log2Size[param.minCUSize] + 1; i++)
> @@ -184,46 +185,50 @@
>          else
>              fputs(" -,", csvfp);
>      }
> -    for (uint32_t depth = 0; depth <= param.maxCUDepth; depth++)
> -        fprintf(csvfp, "%5.2lf%%, %5.2lf%%, %5.2lf%%,",
> frameStats->cuStats.percentIntraDistribution[depth][0],
> -
> frameStats->cuStats.percentIntraDistribution[depth][1],
> -
> frameStats->cuStats.percentIntraDistribution[depth][2]);
> -    fprintf(csvfp, "%5.2lf%%", frameStats->cuStats.percentIntraNxN);
> -    if (param.bEnableRectInter)
> +
> +    if (level)
>      {
>          for (uint32_t depth = 0; depth <= param.maxCUDepth; depth++)
> +            fprintf(csvfp, "%5.2lf%%, %5.2lf%%, %5.2lf%%,",
> frameStats->cuStats.percentIntraDistribution[depth][0],
> +            frameStats->cuStats.percentIntraDistribution[depth][1],
> +            frameStats->cuStats.percentIntraDistribution[depth][2]);
> +        fprintf(csvfp, "%5.2lf%%", frameStats->cuStats.percentIntraNxN);
> +        if (param.bEnableRectInter)
>          {
> -            fprintf(csvfp, ", %5.2lf%%, %5.2lf%%", frameStats->cuStats.
> percentInterDistribution[depth][0],
> -                                                   frameStats->cuStats.
> percentInterDistribution[depth][1]);
> -            if (param.bEnableAMP)
> -                fprintf(csvfp, ", %5.2lf%%", frameStats->cuStats.
> percentInterDistribution[depth][2]);
> +            for (uint32_t depth = 0; depth <= param.maxCUDepth; depth++)
> +            {
> +                fprintf(csvfp, ", %5.2lf%%, %5.2lf%%",
> frameStats->cuStats.percentInterDistribution[depth][0],
> +                    frameStats->cuStats.percentInterDistribution[
> depth][1]);
> +                if (param.bEnableAMP)
> +                    fprintf(csvfp, ", %5.2lf%%", frameStats->cuStats.
> percentInterDistribution[depth][2]);
> +            }
>          }
> -    }
> -    else
> -    {
> +        else
> +        {
> +            for (uint32_t depth = 0; depth <= param.maxCUDepth; depth++)
> +                fprintf(csvfp, ", %5.2lf%%", frameStats->cuStats.
> percentInterDistribution[depth][0]);
> +        }
>          for (uint32_t depth = 0; depth <= param.maxCUDepth; depth++)
> -            fprintf(csvfp, ", %5.2lf%%", frameStats->cuStats.
> percentInterDistribution[depth][0]);
> -    }
> -    for (uint32_t depth = 0; depth <= param.maxCUDepth; depth++)
> -        fprintf(csvfp, ", %5.2lf%%", frameStats->cuStats.
> percentSkipCu[depth]);
> -    for (uint32_t depth = 0; depth <= param.maxCUDepth; depth++)
> -        fprintf(csvfp, ", %5.2lf%%", frameStats->cuStats.
> percentMergeCu[depth]);
> -
> -    fprintf(csvfp, ", %.2lf, %.2lf, %.2lf, %.2lf ",
> frameStats->avgLumaDistortion,
> -                                                    frameStats->
> avgChromaDistortion,
> -
> frameStats->avgPsyEnergy,
> -
> frameStats->avgResEnergy);
> -
> -    fprintf(csvfp, ", %d, %d, %.2lf", frameStats->minLumaLevel,
> frameStats->maxLumaLevel, frameStats->avgLumaLevel);
> -
> -    if (param.internalCsp != X265_CSP_I400)
> -    {
> -        fprintf(csvfp, ", %d, %d, %.2lf", frameStats->minChromaULevel,
> frameStats->maxChromaULevel, frameStats->avgChromaULevel);
> -        fprintf(csvfp, ", %d, %d, %.2lf", frameStats->minChromaVLevel,
> frameStats->maxChromaVLevel, frameStats->avgChromaVLevel);
> +            fprintf(csvfp, ", %5.2lf%%", frameStats->cuStats.
> percentSkipCu[depth]);
> +        for (uint32_t depth = 0; depth <= param.maxCUDepth; depth++)
> +            fprintf(csvfp, ", %5.2lf%%", frameStats->cuStats.
> percentMergeCu[depth]);
>      }
>
>      if (level >= 2)
>      {
> +        fprintf(csvfp, ", %.2lf, %.2lf, %.2lf, %.2lf ",
> frameStats->avgLumaDistortion,
> +            frameStats->avgChromaDistortion,
> +            frameStats->avgPsyEnergy,
> +            frameStats->avgResEnergy);
> +
> +        fprintf(csvfp, ", %d, %d, %.2lf", frameStats->minLumaLevel,
> frameStats->maxLumaLevel, frameStats->avgLumaLevel);
> +
> +        if (param.internalCsp != X265_CSP_I400)
> +        {
> +            fprintf(csvfp, ", %d, %d, %.2lf",
> frameStats->minChromaULevel, frameStats->maxChromaULevel,
> frameStats->avgChromaULevel);
> +            fprintf(csvfp, ", %d, %d, %.2lf",
> frameStats->minChromaVLevel, frameStats->maxChromaVLevel,
> frameStats->avgChromaVLevel);
> +        }
> +
>          for (uint32_t i = 0; i < param.maxLog2CUSize -
> (uint32_t)g_log2Size[param.minCUSize] + 1; i++)
>          {
>              fprintf(csvfp, ", %.2lf%%", frameStats->puStats.
> percentIntraPu[i]);
> _______________________________________________
> 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/20170623/f1ab740b/attachment-0001.html>


More information about the x265-devel mailing list