[x265] [PATCH] stats: average and maximum luma level per frame
Deepthi Nandakumar
deepthi at multicorewareinc.com
Tue Jul 28 09:28:46 CEST 2015
On Mon, Jul 27, 2015 at 3:18 PM, Divya Manivannan <
divya at multicorewareinc.com> wrote:
> # HG changeset patch
> # User Divya Manivannan <divya at multicorewareinc.com>
> # Date 1437990335 -19800
> # Mon Jul 27 15:15:35 2015 +0530
> # Node ID 8c160e96251d2bd88afb6adff5d117a0b75d1412
> # Parent b015514a93868e2dcf431d2e94b147861076a376
> stats: average and maximum luma level per frame
>
> diff -r b015514a9386 -r 8c160e96251d source/CMakeLists.txt
> --- a/source/CMakeLists.txt Sun Jul 26 16:12:32 2015 +0530
> +++ b/source/CMakeLists.txt Mon Jul 27 15:15:35 2015 +0530
> @@ -30,7 +30,7 @@
> mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
>
> # X265_BUILD must be incremented each time the public API is changed
> -set(X265_BUILD 67)
> +set(X265_BUILD 68)
> configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
> "${PROJECT_BINARY_DIR}/x265.def")
> configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
> diff -r b015514a9386 -r 8c160e96251d source/common/framedata.h
> --- a/source/common/framedata.h Sun Jul 26 16:12:32 2015 +0530
> +++ b/source/common/framedata.h Mon Jul 27 15:15:35 2015 +0530
> @@ -55,6 +55,7 @@
> double avgLumaDistortion;
> double avgChromaDistortion;
> double avgPsyEnergy;
> + double avgLumaLevel;
> double percentIntraNxN;
> double percentSkipCu[NUM_CU_DEPTH];
> double percentMergeCu[NUM_CU_DEPTH];
> @@ -67,12 +68,15 @@
> uint64_t lumaDistortion;
> uint64_t chromaDistortion;
> uint64_t psyEnergy;
> + uint64_t lumaLevel;
> + uint64_t noOfPixels;
> uint64_t cntSkipCu[NUM_CU_DEPTH];
> uint64_t cntMergeCu[NUM_CU_DEPTH];
> uint64_t cntInter[NUM_CU_DEPTH];
> uint64_t cntIntra[NUM_CU_DEPTH];
> uint64_t cuInterDistribution[NUM_CU_DEPTH][INTER_MODES];
> uint64_t cuIntraDistribution[NUM_CU_DEPTH][INTRA_MODES];
> + uint16_t maxLumaLevel;
>
> FrameStats()
> {
> diff -r b015514a9386 -r 8c160e96251d source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp Sun Jul 26 16:12:32 2015 +0530
> +++ b/source/encoder/encoder.cpp Mon Jul 27 15:15:35 2015 +0530
> @@ -1168,6 +1168,8 @@
> 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->avgLumaLevel =
> curFrame->m_encData->m_frameStats.avgLumaLevel;
> + frameStats->maxLumaLevel =
> curFrame->m_encData->m_frameStats.maxLumaLevel;
> for (uint32_t depth = 0; depth <= g_maxCUDepth; depth++)
> {
> frameStats->cuStats.percentSkipCu[depth] =
> curFrame->m_encData->m_frameStats.percentSkipCu[depth];
> diff -r b015514a9386 -r 8c160e96251d source/encoder/frameencoder.cpp
> --- a/source/encoder/frameencoder.cpp Sun Jul 26 16:12:32 2015 +0530
> +++ b/source/encoder/frameencoder.cpp Mon Jul 27 15:15:35 2015 +0530
> @@ -591,6 +591,11 @@
> 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.lumaLevel +=
> m_rows[i].rowStats.lumaLevel;
> + m_frame->m_encData->m_frameStats.noOfPixels +=
> m_rows[i].rowStats.noOfPixels;
> +
> + if (m_rows[i].rowStats.maxLumaLevel >
> m_frame->m_encData->m_frameStats.maxLumaLevel)
> + m_frame->m_encData->m_frameStats.maxLumaLevel =
> m_rows[i].rowStats.maxLumaLevel;
> for (uint32_t depth = 0; depth <= g_maxCUDepth; depth++)
> {
> m_frame->m_encData->m_frameStats.cntSkipCu[depth] +=
> m_rows[i].rowStats.cntSkipCu[depth];
> @@ -604,6 +609,7 @@
> 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.avgLumaLevel =
> (double)(m_frame->m_encData->m_frameStats.lumaLevel /
> m_frame->m_encData->m_frameStats.noOfPixels);
>
I was trying to figure out whether a better approach is to average per CTU.
With float/double datatypes - overflow is not a problem, but precision is.
> 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 <= g_maxCUDepth; depth++)
> {
> @@ -983,6 +989,13 @@
> for (int n = 0; n < INTRA_MODES; n++)
> curRow.rowStats.cuIntraDistribution[depth][n] +=
> frameLog.cuIntraDistribution[depth][n];
> }
> + for (uint32_t i = 0; i < (best.reconYuv.m_size *
> best.reconYuv.m_size); i++)
> + {
> + curRow.rowStats.lumaLevel += *(best.reconYuv.m_buf[0] + i);
> + curRow.rowStats.noOfPixels++;
> + if ((*(best.reconYuv.m_buf[0] + i)) >
> curRow.rowStats.maxLumaLevel)
> + curRow.rowStats.maxLumaLevel = *(best.reconYuv.m_buf[0] +
> i);
> + }
>
> curEncData.m_cuStat[cuAddr].totalBits = best.totalBits;
> x265_emms();
> diff -r b015514a9386 -r 8c160e96251d source/x265-extras.cpp
> --- a/source/x265-extras.cpp Sun Jul 26 16:12:32 2015 +0530
> +++ b/source/x265-extras.cpp Mon Jul 27 15:15:35 2015 +0530
> @@ -107,7 +107,7 @@
> fprintf(csvfp, ", Merge %dx%d", size, size);
> size /= 2;
> }
> - fprintf(csvfp, ", Avg Luma Distortion, Avg Chroma
> Distortion, Avg psyEnergy");
> + fprintf(csvfp, ", Avg Luma Distortion, Avg Chroma
> Distortion, Avg psyEnergy, Avg Luma Level, Max Luma Level");
> }
> fprintf(csvfp, "\n");
> }
> @@ -179,7 +179,7 @@
> fprintf(csvfp, ", %5.2lf%%",
> frameStats->cuStats.percentSkipCu[depth]);
> for (uint32_t depth = 0; depth <= g_maxCUDepth; depth++)
> fprintf(csvfp, ", %5.2lf%%",
> frameStats->cuStats.percentMergeCu[depth]);
> - fprintf(csvfp, ", %.2lf, %.2lf, %.2lf",
> frameStats->avgLumaDistortion, frameStats->avgChromaDistortion,
> frameStats->avgPsyEnergy);
> + fprintf(csvfp, ", %.2lf, %.2lf, %.2lf, %.2lf, %d",
> frameStats->avgLumaDistortion, frameStats->avgChromaDistortion,
> frameStats->avgPsyEnergy, frameStats->avgLumaLevel,
> frameStats->maxLumaLevel);
> }
> fprintf(csvfp, "\n");
> fflush(stderr);
> diff -r b015514a9386 -r 8c160e96251d source/x265.h
> --- a/source/x265.h Sun Jul 26 16:12:32 2015 +0530
> +++ b/source/x265.h Mon Jul 27 15:15:35 2015 +0530
> @@ -132,12 +132,14 @@
> double avgLumaDistortion;
> double avgChromaDistortion;
> double avgPsyEnergy;
> + double avgLumaLevel;
> uint64_t bits;
> int encoderOrder;
> int poc;
> int countRowBlocks;
> int list0POC[16];
> int list1POC[16];
> + uint16_t maxLumaLevel;
> char sliceType;
> x265_cu_stats cuStats;
> } x265_frame_stats;
> _______________________________________________
> 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/20150728/06a379f1/attachment-0001.html>
More information about the x265-devel
mailing list