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

Steve Borho steve at borho.org
Thu Aug 6 18:12:01 CEST 2015


On 08/06, Divya Manivannan wrote:
> # HG changeset patch
> # User Divya Manivannan <divya at multicorewareinc.com>
> # Date 1438844729 -19800
> #      Thu Aug 06 12:35:29 2015 +0530
> # Node ID 1ef3394a866a79dc9735ed61fe37f4a8c55b7a64
> # Parent  377a996a8d74110f838ff2e3cef1c42781d6d730
> stats: average residual energy after motion prediction per frame
> 
> diff -r 377a996a8d74 -r 1ef3394a866a source/CMakeLists.txt
> --- a/source/CMakeLists.txt	Wed Aug 05 15:09:14 2015 +0530
> +++ b/source/CMakeLists.txt	Thu Aug 06 12:35:29 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 68)
> +set(X265_BUILD 69)
>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
>                 "${PROJECT_BINARY_DIR}/x265.def")
>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
> diff -r 377a996a8d74 -r 1ef3394a866a source/common/framedata.h
> --- a/source/common/framedata.h	Wed Aug 05 15:09:14 2015 +0530
> +++ b/source/common/framedata.h	Thu Aug 06 12:35:29 2015 +0530
> @@ -55,6 +55,7 @@
>      double      avgLumaDistortion;
>      double      avgChromaDistortion;
>      double      avgPsyEnergy;
> +    double      avgResEnergy;
>      double      avgLumaLevel;
>      double      lumaLevel;
>      double      percentIntraNxN;
> @@ -69,6 +70,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 377a996a8d74 -r 1ef3394a866a source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp	Wed Aug 05 15:09:14 2015 +0530
> +++ b/source/encoder/encoder.cpp	Thu Aug 06 12:35:29 2015 +0530
> @@ -1168,6 +1168,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_encData->m_frameStats.avgLumaLevel;
>          frameStats->maxLumaLevel            = curFrame->m_encData->m_frameStats.maxLumaLevel;
>          for (uint32_t depth = 0; depth <= g_maxCUDepth; depth++)
> diff -r 377a996a8d74 -r 1ef3394a866a source/encoder/frameencoder.cpp
> --- a/source/encoder/frameencoder.cpp	Wed Aug 05 15:09:14 2015 +0530
> +++ b/source/encoder/frameencoder.cpp	Thu Aug 06 12:35:29 2015 +0530
> @@ -591,6 +591,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;
>          m_frame->m_encData->m_frameStats.lumaLevel        += m_rows[i].rowStats.lumaLevel;
>  
>          if (m_rows[i].rowStats.maxLumaLevel > m_frame->m_encData->m_frameStats.maxLumaLevel)
> @@ -608,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.avgResEnergy        = (double)(m_frame->m_encData->m_frameStats.resEnergy / 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.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++)
> @@ -977,6 +979,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 377a996a8d74 -r 1ef3394a866a source/encoder/search.cpp
> --- a/source/encoder/search.cpp	Wed Aug 05 15:09:14 2015 +0530
> +++ b/source/encoder/search.cpp	Thu Aug 06 12:35:29 2015 +0530
> @@ -1190,6 +1190,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);
>  }
> @@ -1402,6 +1404,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);
> @@ -2447,6 +2450,7 @@
>      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");
>  
> @@ -2480,6 +2484,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);
> @@ -2592,6 +2597,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;
> diff -r 377a996a8d74 -r 1ef3394a866a source/encoder/search.h
> --- a/source/encoder/search.h	Wed Aug 05 15:09:14 2015 +0530
> +++ b/source/encoder/search.h	Thu Aug 06 12:35:29 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
> +    uint64_t   resEnergy;  // sum of partition residual energy after motion prediction
>      uint32_t   lumaDistortion;

resEnergy uses the same primitive as lumaDistortion (one uses predYuv,
the other uses reconYuv), so why does resEnergy need to be uint64_t?

>      uint32_t   chromaDistortion;
>      uint32_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;
> @@ -137,6 +139,7 @@
>          sa8dCost = UINT64_MAX / 2;
>          sa8dBits = MAX_UINT / 2;
>          psyEnergy = MAX_UINT / 2;
> +        resEnergy = UINT64_MAX / 2;
>          lumaDistortion = MAX_UINT / 2;
>          chromaDistortion = MAX_UINT / 2;
>          distortion = MAX_UINT / 2;
> @@ -151,6 +154,7 @@
>                   sa8dCost >= UINT64_MAX / 2 ||
>                   sa8dBits >= MAX_UINT / 2 ||
>                   psyEnergy >= MAX_UINT / 2 ||
> +                 resEnergy >= UINT64_MAX / 2 ||
>                   lumaDistortion >= MAX_UINT / 2 ||
>                   chromaDistortion >= MAX_UINT / 2 ||
>                   distortion >= MAX_UINT / 2 ||
> @@ -167,6 +171,7 @@
>          sa8dCost += subMode.sa8dCost;
>          sa8dBits += subMode.sa8dBits;
>          psyEnergy += subMode.psyEnergy;
> +        resEnergy += subMode.resEnergy;
>          lumaDistortion += subMode.lumaDistortion;
>          chromaDistortion += subMode.chromaDistortion;
>          distortion += subMode.distortion;
> diff -r 377a996a8d74 -r 1ef3394a866a source/x265-extras.cpp
> --- a/source/x265-extras.cpp	Wed Aug 05 15:09:14 2015 +0530
> +++ b/source/x265-extras.cpp	Thu Aug 06 12:35:29 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");
>                  }
>                  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, %.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);
>      }
>      fprintf(csvfp, "\n");
>      fflush(stderr);
> diff -r 377a996a8d74 -r 1ef3394a866a source/x265.h
> --- a/source/x265.h	Wed Aug 05 15:09:14 2015 +0530
> +++ b/source/x265.h	Thu Aug 06 12:35:29 2015 +0530
> @@ -132,6 +132,7 @@
>      double           avgLumaDistortion;
>      double           avgChromaDistortion;
>      double           avgPsyEnergy;
> +    double           avgResEnergy;
>      double           avgLumaLevel;
>      uint64_t         bits;
>      int              encoderOrder;
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel

-- 
Steve Borho


More information about the x265-devel mailing list