Skip to content

Commit

Permalink
VPYInput: Improve logMessageHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
DJATOM committed Sep 2, 2024
1 parent a5c8f23 commit 07556a3
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions source/input/vpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,26 @@

using namespace X265_NS;

const char *messageTypeToString(int msgType)
{
switch (msgType)
{
case mtDebug: return "Debug";
case mtInformation: return "Information";
case mtWarning: return "Warning";
case mtCritical: return "Critical";
case mtFatal: return "Fatal";
default: return "Other";
}
}

void VS_CC frameDoneCallback(void* userData, const VSFrame* f, const int n, VSNode*, const char* errorMsg)
{
reinterpret_cast<VPYInput*>(userData)->setAsyncFrame(n, f, errorMsg);
}

void VS_CC logMessageHandler(int msgType, const char* msg, void*)
{
if (msgType >= mtInformation)
general_log(nullptr, "vpy", X265_LOG_INFO, "%s: %s\n", messageTypeToString(msgType), msg);
auto vsToX265LogLevel = [msgType]()
{
switch (msgType)
{
case mtDebug: return X265_LOG_DEBUG;
case mtInformation: return X265_LOG_INFO;
case mtWarning: return X265_LOG_WARNING;
case mtCritical: return X265_LOG_WARNING;
case mtFatal: return X265_LOG_ERROR;
default: return X265_LOG_FULL;
}
};
general_log(nullptr, "vpy", vsToX265LogLevel(), "%s\n", msg);
}

void VPYInput::setAsyncFrame(int n, const VSFrame* f, const char* errorMsg)
Expand Down

0 comments on commit 07556a3

Please sign in to comment.