[x265] [PATCH] stats: average residual energy after motion prediction per frame

Divya Manivannan divya at multicorewareinc.com
Mon Aug 24 10:38:02 CEST 2015


# HG changeset patch
# User Divya Manivannan <divya at multicorewareinc.com>
# Date 1440405272 -19800
#      Mon Aug 24 14:04:32 2015 +0530
# Node ID c8b7eb05e94b0a27f578884a39c39ffcae5cbeb0
# Parent  60f30d2ead26e22b7f7e196db44da1a78b929513
stats: average residual energy after motion prediction per frame

diff -r 60f30d2ead26 -r c8b7eb05e94b source/CMakeLists.txt
--- a/source/CMakeLists.txt	Fri Aug 21 15:53:24 2015 +0530
+++ b/source/CMakeLists.txt	Mon Aug 24 14:04:32 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 71)
+set(X265_BUILD 72)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r 60f30d2ead26 -r c8b7eb05e94b source/common/framedata.h
--- a/source/common/framedata.h	Fri Aug 21 15:53:24 2015 +0530
+++ b/source/common/framedata.h	Mon Aug 24 14:04:32 2015 +0530
@@ -55,6 +55,7 @@
     double      avgLumaDistortion;
     double      avgChromaDistortion;
     double      avgPsyEnergy;
+    double      avgResEnergy;
     double      percentIntraNxN;
     double      percentSkipCu[NUM_CU_DEPTH];
     double      percentMergeCu[NUM_CU_DEPTH];
@@ -67,6 +68,7 @@
     uint64_t    lumaDistortion;
     uint64_t    chromaDistortion;
     uint64_t    psyEnergy;
+    uint64_t    resEnergy;
     uint64_t    cntSkipCu[NUM_CU_DEPTH];
     uint64_t    cntMergeCu[NUM_CU_DEPTH];
     uint64_t    cntInter[NUM_CU_DEPTH];
diff -r 60f30d2ead26 -r c8b7eb05e94b source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Fri Aug 21 15:53:24 2015 +0530
+++ b/source/encoder/encoder.cpp	Mon Aug 24 14:04:32 2015 +0530
@@ -1172,6 +1172,7 @@
         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;
         for (uint32_t depth = 0; depth <= g_maxCUDepth; depth++)
diff -r 60f30d2ead26 -r c8b7eb05e94b source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Fri Aug 21 15:53:24 2015 +0530
+++ b/source/encoder/frameencoder.cpp	Mon Aug 24 14:04:32 2015 +0530
@@ -592,7 +592,7 @@
         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.resEnergy        += m_rows[i].rowStats.resEnergy;
         for (uint32_t depth = 0; depth <= g_maxCUDepth; depth++)
         {
             m_frame->m_encData->m_frameStats.cntSkipCu[depth] += m_rows[i].rowStats.cntSkipCu[depth];
@@ -606,6 +606,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.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 <= g_maxCUDepth; depth++)
     {
@@ -975,6 +976,7 @@
         curRow.rowStats.lumaDistortion   += best.lumaDistortion;
         curRow.rowStats.chromaDistortion += best.chromaDistortion;
         curRow.rowStats.psyEnergy        += best.psyEnergy;
+        curRow.rowStats.resEnergy        += best.resEnergy;
         curRow.rowStats.cntIntraNxN      += frameLog.cntIntraNxN;
         curRow.rowStats.totalCu          += frameLog.totalCu;
         for (uint32_t depth = 0; depth <= g_maxCUDepth; depth++)
diff -r 60f30d2ead26 -r c8b7eb05e94b source/encoder/search.cpp
--- a/source/encoder/search.cpp	Fri Aug 21 15:53:24 2015 +0530
+++ b/source/encoder/search.cpp	Mon Aug 24 14:04:32 2015 +0530
@@ -1196,6 +1196,8 @@
         const Yuv* fencYuv = intraMode.fencYuv;
         intraMode.psyEnergy = m_rdCost.psyCost(cuGeom.log2CUSize - 2, fencYuv->m_buf[0], fencYuv->m_size, intraMode.reconYuv.m_buf[0], intraMode.reconYuv.m_size);
     }
+    intraMode.resEnergy = primitives.cu[cuGeom.log2CUSize - 2].sse_pp(intraMode.fencYuv->m_buf[0], intraMode.fencYuv->m_size, intraMode.predYuv.m_buf[0], intraMode.predYuv.m_size);
+
     updateModeCost(intraMode);
     checkDQP(intraMode, cuGeom);
 }
@@ -1408,7 +1410,7 @@
         const Yuv* fencYuv = intraMode.fencYuv;
         intraMode.psyEnergy = m_rdCost.psyCost(cuGeom.log2CUSize - 2, fencYuv->m_buf[0], fencYuv->m_size, reconYuv->m_buf[0], reconYuv->m_size);
     }
-
+    intraMode.resEnergy = primitives.cu[cuGeom.log2CUSize - 2].sse_pp(intraMode.fencYuv->m_buf[0], intraMode.fencYuv->m_size, intraMode.predYuv.m_buf[0], intraMode.predYuv.m_size);
     m_entropyCoder.store(intraMode.contexts);
     updateModeCost(intraMode);
     checkDQP(intraMode, cuGeom);
@@ -2455,9 +2457,8 @@
     CUData& cu = interMode.cu;
     Yuv* reconYuv = &interMode.reconYuv;
     const Yuv* fencYuv = interMode.fencYuv;
-
+    Yuv* predYuv = &interMode.predYuv;
     X265_CHECK(!cu.isIntra(0), "intra CU not expected\n");
-
     uint32_t depth  = cu.m_cuDepth[0];
 
     // No residual coding : SKIP mode
@@ -2488,7 +2489,7 @@
     interMode.totalBits = interMode.mvBits;
     if (m_rdCost.m_psyRd)
         interMode.psyEnergy = m_rdCost.psyCost(part, fencYuv->m_buf[0], fencYuv->m_size, reconYuv->m_buf[0], reconYuv->m_size);
-
+    interMode.resEnergy = primitives.cu[part].sse_pp(fencYuv->m_buf[0], fencYuv->m_size, predYuv->m_buf[0], predYuv->m_size);
     updateModeCost(interMode);
     m_entropyCoder.store(interMode.contexts);
 }
@@ -2600,7 +2601,7 @@
     bestChromaDist += m_rdCost.scaleChromaDist(2, primitives.chroma[m_csp].cu[sizeIdx].sse_pp(fencYuv->m_buf[2], fencYuv->m_csize, reconYuv->m_buf[2], reconYuv->m_csize));
     if (m_rdCost.m_psyRd)
         interMode.psyEnergy = m_rdCost.psyCost(sizeIdx, fencYuv->m_buf[0], fencYuv->m_size, reconYuv->m_buf[0], reconYuv->m_size);
-
+    interMode.resEnergy = primitives.cu[sizeIdx].sse_pp(fencYuv->m_buf[0], fencYuv->m_size, predYuv->m_buf[0], predYuv->m_size);
     interMode.totalBits = bits;
     interMode.lumaDistortion = bestLumaDist;
     interMode.chromaDistortion = bestChromaDist;
diff -r 60f30d2ead26 -r c8b7eb05e94b source/encoder/search.h
--- a/source/encoder/search.h	Fri Aug 21 15:53:24 2015 +0530
+++ b/source/encoder/search.h	Mon Aug 24 14:04:32 2015 +0530
@@ -109,6 +109,7 @@
     uint64_t   sa8dCost;   // sum of partition sa8d distortion costs   (sa8d(fenc, pred) + lambda * bits)
     uint32_t   sa8dBits;   // signal bits used in sa8dCost calculation
     uint32_t   psyEnergy;  // sum of partition psycho-visual energy difference
+    sse_ret_t  resEnergy;  // sum of partition residual energy after motion prediction
     sse_ret_t  lumaDistortion;
     sse_ret_t  chromaDistortion;
     sse_ret_t  distortion; // sum of partition SSE distortion
@@ -122,6 +123,7 @@
         sa8dCost = 0;
         sa8dBits = 0;
         psyEnergy = 0;
+        resEnergy = 0;
         lumaDistortion = 0;
         chromaDistortion = 0;
         distortion = 0;
@@ -138,10 +140,12 @@
         sa8dBits = MAX_UINT / 2;
         psyEnergy = MAX_UINT / 2;
 #if X265_DEPTH <= 10
+        resEnergy = MAX_UINT / 2;
         lumaDistortion = MAX_UINT / 2;
         chromaDistortion = MAX_UINT / 2;
         distortion = MAX_UINT / 2;
 #else
+        resEnergy = UINT64_MAX / 2;
         lumaDistortion = UINT64_MAX / 2;
         chromaDistortion = UINT64_MAX / 2;
         distortion = UINT64_MAX / 2;
@@ -158,6 +162,7 @@
             sa8dCost >= UINT64_MAX / 2 ||
             sa8dBits >= MAX_UINT / 2 ||
             psyEnergy >= MAX_UINT / 2 ||
+            resEnergy >= MAX_UINT / 2 ||
             lumaDistortion >= MAX_UINT / 2 ||
             chromaDistortion >= MAX_UINT / 2 ||
             distortion >= MAX_UINT / 2 ||
@@ -169,6 +174,7 @@
                  sa8dCost >= UINT64_MAX / 2 ||
                  sa8dBits >= MAX_UINT / 2 ||
                  psyEnergy >= MAX_UINT / 2 ||
+                 resEnergy >= UINT64_MAX / 2 ||
                  lumaDistortion >= UINT64_MAX / 2 ||
                  chromaDistortion >= UINT64_MAX / 2 ||
                  distortion >= UINT64_MAX / 2 ||
@@ -186,6 +192,7 @@
         sa8dCost += subMode.sa8dCost;
         sa8dBits += subMode.sa8dBits;
         psyEnergy += subMode.psyEnergy;
+        resEnergy += subMode.resEnergy;
         lumaDistortion += subMode.lumaDistortion;
         chromaDistortion += subMode.chromaDistortion;
         distortion += subMode.distortion;
diff -r 60f30d2ead26 -r c8b7eb05e94b source/x265-extras.cpp
--- a/source/x265-extras.cpp	Fri Aug 21 15:53:24 2015 +0530
+++ b/source/x265-extras.cpp	Mon Aug 24 14:04:32 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, Avg Luma Level, Max Luma Level");
+                fprintf(csvfp, ", Avg Luma Distortion, Avg Chroma Distortion, Avg psyEnergy, Avg Luma Level, Max Luma Level, Avg Residual Energy");
 
                 /* detailed performance statistics */
                 if (level >= 2)
@@ -174,7 +174,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, %.2lf, %d", frameStats->avgLumaDistortion, frameStats->avgChromaDistortion, frameStats->avgPsyEnergy, frameStats->avgLumaLevel, frameStats->maxLumaLevel);
+    fprintf(csvfp, ", %.2lf, %.2lf, %.2lf, %.2lf, %d, %.2lf", frameStats->avgLumaDistortion, frameStats->avgChromaDistortion, frameStats->avgPsyEnergy, frameStats->avgLumaLevel, frameStats->maxLumaLevel, frameStats->avgResEnergy);
 
     if (level >= 2)
     {
diff -r 60f30d2ead26 -r c8b7eb05e94b source/x265.h
--- a/source/x265.h	Fri Aug 21 15:53:24 2015 +0530
+++ b/source/x265.h	Mon Aug 24 14:04:32 2015 +0530
@@ -132,6 +132,7 @@
     double           avgLumaDistortion;
     double           avgChromaDistortion;
     double           avgPsyEnergy;
+    double           avgResEnergy;
     double           avgLumaLevel;
     uint64_t         bits;
     int              encoderOrder;


More information about the x265-devel mailing list