Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into clarify-tooltip-bar…
Browse files Browse the repository at this point in the history
…chart
  • Loading branch information
dericed committed Jun 1, 2018
2 parents 0290988 + 25f45f8 commit 5d8cf82
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 8 deletions.
6 changes: 1 addition & 5 deletions Source/Core/CommonStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -193,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
};
Expand Down Expand Up @@ -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<CountOfItems; Plot_Pos++)
y[Plot_Pos][1]= y[Plot_Pos][0];
x_Current++;
}

// Forcing max values to the last real ones, in case max values were estimated
Expand Down
45 changes: 43 additions & 2 deletions Source/Core/CommonStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
#define CommonStats_H

#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <stdint.h>
#include <algorithm>
#include <cctype>
#include <Core/Core.h>

using namespace std;
Expand Down Expand Up @@ -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",
Expand All @@ -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;
Expand Down
12 changes: 11 additions & 1 deletion Source/Core/FFmpeg_Glue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -1319,6 +1322,13 @@ bool FFmpeg_Glue::OutputFrame(AVPacket* TempPacket, bool Decode)
{
TempPacket->data+=TempPacket->size;
TempPacket->size=0;

for (size_t OutputPos=0; OutputPos<OutputDatas.size(); OutputPos++)
if (OutputDatas[OutputPos] && OutputDatas[OutputPos]->Enabled && OutputDatas[OutputPos]->Stream==InputData->Stream) {
if(!OutputDatas[OutputPos]->Filter.empty()) // flush delayed filtered frames
OutputDatas[OutputPos]->Process(nullptr);
}

return false;
}
TempPacket->data+=Bytes;
Expand Down

0 comments on commit 5d8cf82

Please sign in to comment.