Skip to content

Commit

Permalink
Print short unknown type data if all characters are ascii printable
Browse files Browse the repository at this point in the history
  • Loading branch information
myrsloik committed Sep 18, 2023
1 parent 8d3a384 commit 33e9774
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
r64:
added json output of video frame properties to vspipe
fixed clearMap function, previously it would forget to properly clear the error state in maps which could cause crashes in frameeval and other filters
32 bit binaries are no longer provided for windows
updated zimg to fix issues on zen4 cpus
Expand Down
2 changes: 1 addition & 1 deletion src/avisynth/avisynth_compat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ static void VS_CC fakeAvisynthFunctionWrapper(const VSMap *in, VSMap *out, void
avisynthFilterFree,
(preFetchClips.empty() || prefetchInfo.from > prefetchInfo.to) ? fmFrameState : fmParallelRequests,
deps.data(),
preFetchClips.size(),
static_cast<int>(preFetchClips.size()),
filterData.release(),
core);

Expand Down
9 changes: 8 additions & 1 deletion src/vspipe/vsjson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
#include "vsjson.h"
#include "clocale"

static bool isAsciiPrintable(const std::string &s) {
for (const auto c : s)
if (c < 0x20 || c > 0x7E)
return false;
return true;
}

static std::string doubleToString(double v) {
std::string result = std::to_string(v);
char point = *localeconv()->decimal_point;
Expand Down Expand Up @@ -90,7 +97,7 @@ std::string convertVSMapToJSON(const VSMap *map, const VSAPI *vsapi) {
for (int j = 0; j < numElems; j++) {
int typeHint = vsapi->mapGetDataTypeHint(map, key, j, nullptr);
jsonStr += (j ? ", " : "");
if (typeHint == dtUtf8)
if (typeHint == dtUtf8 || (typeHint == dtUnknown && vsapi->mapGetDataSize(map, key, j, nullptr) < 200 && isAsciiPrintable(std::string(vsapi->mapGetData(map, key, j, nullptr), vsapi->mapGetDataSize(map, key, j, nullptr)))))
jsonStr += escapeJSONString(vsapi->mapGetData(map, key, j, nullptr));
else
jsonStr += "\"[binary data size: " + std::to_string(vsapi->mapGetDataSize(map, key, j, nullptr)) + "]\"";
Expand Down

0 comments on commit 33e9774

Please sign in to comment.