diff --git a/source/App/EncoderApp/encmain.cpp b/source/App/EncoderApp/encmain.cpp index 971aef526a43f16b179206ecd6d1617a84e4284f..d15232cb0cfdd5280e6511c130b2da7d9ec60c0e 100644 --- a/source/App/EncoderApp/encmain.cpp +++ b/source/App/EncoderApp/encmain.cpp @@ -76,6 +76,33 @@ static void printMacroSettings() } } +#if JVET_Z0150_MEMORY_USAGE_PRINT +#ifdef __linux +#include <cstdlib> +#include <cstdio> +#include <cstring> + +int getProcStatusValue(const char* key) +{ + FILE* file = fopen("/proc/self/status", "r"); + int result = -1; + char line[128]; + + int len = strlen(key); + while (fgets(line, 128, file) != nullptr) + { + if (strncmp(line, key, len) == 0) + { + result = atoi(line+len); + break; + } + } + fclose(file); + return result; +} +#endif +#endif + // ==================================================================================================================== // Main function // ==================================================================================================================== @@ -325,6 +352,15 @@ int main(int argc, char* argv[]) encApp->applyNnPostFilter(); } } + +#if JVET_Z0150_MEMORY_USAGE_PRINT +#ifdef __linux + int vm = getProcStatusValue("VmPeak:"); + int rm = getProcStatusValue("VmHWM:"); + printf("\nMemory Usage: VmPeak= %d KB ( %.1f GiB ), VmHWM= %d KB ( %.1f GiB )\n", vm, (double)vm/(1024*1024), rm, (double)rm/(1024*1024)); +#endif +#endif + // ending time clock_t endClock = clock(); auto endTime = std::chrono::steady_clock::now(); diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 9f4b0205cd15bc362ae584c2443045ef878b0a21..af8db417c3d1b02ba4c4e425e817e091bcf93812 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -58,6 +58,8 @@ //########### place macros to be removed in next cycle below this line ############### +#define JVET_Z0150_MEMORY_USAGE_PRINT 1 // JVET-Z0150: Print memory usage + #define JVET_AE0060_COND_SIG_INF 1 // signal nnpfc_chroma_loc_info_present_flag only when nnpfc_out_order_idc is not equal to 0 and infer nnpfc_chroma_loc_info_present_flag to be equal to 0 when not present. #define JVET_AE0057_MTT_ET 1 // JVET-AE0057: MTT split modes early termination