From 588579f0c553136efbc0686ee2d2a2a0f658f6be Mon Sep 17 00:00:00 2001 From: beholder Date: Thu, 31 May 2018 18:23:18 +0300 Subject: [PATCH 1/3] removed 1frame adaptation --- Source/Core/CommonStats.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Source/Core/CommonStats.cpp b/Source/Core/CommonStats.cpp index 5839c5fff..a84db63ef 100644 --- a/Source/Core/CommonStats.cpp +++ b/Source/Core/CommonStats.cpp @@ -46,9 +46,6 @@ CommonStats::CommonStats (const struct per_item* PerItem_, int Type_, size_t Cou additionalIntStats(nullptr), additionalStringStats(nullptr) { - // Adaptation for having a graph even with 1 frame - if (FrameCount<2) - FrameCount=2; int sizeOfLastStatsIndex = sizeof lastStatsIndexByValueType; memset(lastStatsIndexByValueType, 0, sizeOfLastStatsIndex); @@ -315,7 +312,6 @@ void CommonStats::StatsFinish () x[3][1]=durations[0]?(durations[0]/3600):1; //forcing to 1 in case duration is not available for (size_t Plot_Pos=0; Plot_Pos Date: Thu, 31 May 2018 18:23:54 +0300 Subject: [PATCH 2/3] flush filtering pipeline --- Source/Core/FFmpeg_Glue.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/Core/FFmpeg_Glue.cpp b/Source/Core/FFmpeg_Glue.cpp index 7fed40740..04ab5bc2d 100755 --- a/Source/Core/FFmpeg_Glue.cpp +++ b/Source/Core/FFmpeg_Glue.cpp @@ -465,7 +465,10 @@ void FFmpeg_Glue::outputdata::ApplyFilter(const AVFramePtr& sourceFrame) // Pull filtered frames from the filtergraph FilteredFrame = AVFramePtr(av_frame_alloc(), FilteredFrameDeleter::free); - av_frame_copy_props(FilteredFrame.get(), sourceFrame.get()); + + if(sourceFrame) { + av_frame_copy_props(FilteredFrame.get(), sourceFrame.get()); + } int GetAnswer = av_buffersink_get_frame(FilterGraph_Sink_Context, FilteredFrame.get()); //TODO: handling of multiple output per input if (GetAnswer==AVERROR(EAGAIN) || GetAnswer==AVERROR_EOF) @@ -1319,6 +1322,13 @@ bool FFmpeg_Glue::OutputFrame(AVPacket* TempPacket, bool Decode) { TempPacket->data+=TempPacket->size; TempPacket->size=0; + + for (size_t OutputPos=0; OutputPosEnabled && OutputDatas[OutputPos]->Stream==InputData->Stream) { + if(!OutputDatas[OutputPos]->Filter.empty()) // flush delayed filtered frames + OutputDatas[OutputPos]->Process(nullptr); + } + return false; } TempPacket->data+=Bytes; From 8156ca53cd9c65e5183b0a8f6d90ed223a75d643 Mon Sep 17 00:00:00 2001 From: beholder Date: Thu, 31 May 2018 19:38:14 +0300 Subject: [PATCH 3/3] add some heuristics to better detect stats value type --- Source/Core/CommonStats.cpp | 2 +- Source/Core/CommonStats.h | 45 +++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/Source/Core/CommonStats.cpp b/Source/Core/CommonStats.cpp index a84db63ef..1b1da0b11 100644 --- a/Source/Core/CommonStats.cpp +++ b/Source/Core/CommonStats.cpp @@ -190,7 +190,7 @@ CommonStats::~CommonStats() void CommonStats::processAdditionalStats(const char* key, const char* value, bool statsMapInitialized) { if(!statsMapInitialized) { - auto type = StatsValueInfo::typeFromKey(key); + auto type = StatsValueInfo::typeFromKey(key, value); auto stats = StatsValueInfo { lastStatsIndexByValueType[type]++, type, value }; diff --git a/Source/Core/CommonStats.h b/Source/Core/CommonStats.h index 9fb774637..0ce2e9ff6 100644 --- a/Source/Core/CommonStats.h +++ b/Source/Core/CommonStats.h @@ -9,10 +9,12 @@ #define CommonStats_H #include +#include #include #include #include #include +#include #include using namespace std; @@ -85,7 +87,25 @@ class CommonStats return std::equal(ending.rbegin(), ending.rend(), value.rbegin()); } - static Type typeFromKey(const std::string& key) { + static bool is_number(const std::string& s) + { + int dotCount = 0; + if (s.empty()) + return false; + + for (char c : s ) + { + if ( !(std::isdigit(c) || c == '.' ) && dotCount > 1 ) + { + return false; + } + dotCount += (c == '.'); + } + + return true; + } + + static Type typeFromKey(const std::string& key, const char* value) { static const char* IntEndings[] = { "MIN", "LOW", @@ -112,7 +132,28 @@ class CommonStats return String; } - return Double; + // try to deduce type.. + if(is_number(value)) { + if(strstr(value, ".") != nullptr) { + try { + std::stod(value); + return Double; + } + catch(const std::exception& ex) { + + } + } else { + try { + std::stoi(value); + return Int; + } + catch(const std::exception& ex) { + + } + } + } + + return String; } }; typedef std::string StringStatsKey;