Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Commit

Permalink
Change the frame prop names to psmMin and psmMax
Browse files Browse the repository at this point in the history
  • Loading branch information
dnjulek committed Jul 29, 2022
1 parent 915ea02 commit b91b1b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ psm.PlaneStatsMod(vnode clip[, float minthr=0, float maxthr=0, int plane=0])
### Parameters:

- clip\
A clip to process.
A clip to process.\
Gets frame props named ``psmMin`` and ``psmMax``.
- minthr\
Amount of the smallest pixels dropped before pick the PlaneStatsMin.\
Should be a float between 0.0 and 1.0
Expand Down
20 changes: 4 additions & 16 deletions src/PlaneMinMax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ static const VSFrame* VS_CC planeMinMaxGetFrame(int n, int activationReason, voi

if (pixelsize == 4) {
double retvalminf = retvalmin / 65535.0;
vsapi->mapSetFloat(dstProps, "PlaneStatsMin", retvalminf, maReplace);
vsapi->mapSetFloat(dstProps, "psmMin", retvalminf, maReplace);
}
else {
vsapi->mapSetInt(dstProps, "PlaneStatsMin", retvalmin, maReplace);
vsapi->mapSetInt(dstProps, "psmMin", retvalmin, maReplace);
}
}

Expand All @@ -101,10 +101,10 @@ static const VSFrame* VS_CC planeMinMaxGetFrame(int n, int activationReason, voi

if (pixelsize == 4) {
double retvalmaxf = retvalmax / 65535.0;
vsapi->mapSetFloat(dstProps, "PlaneStatsMax", retvalmaxf, maReplace);
vsapi->mapSetFloat(dstProps, "psmMax", retvalmaxf, maReplace);
}
else {
vsapi->mapSetInt(dstProps, "PlaneStatsMax", retvalmax, maReplace);
vsapi->mapSetInt(dstProps, "psmMax", retvalmax, maReplace);
}
}

Expand Down Expand Up @@ -160,18 +160,6 @@ static void VS_CC planeMinMaxCreate(const VSMap* in, VSMap* out, [[maybe_unused]
return;
}

if (d->minthr == 0 || d->maxthr == 0) {
VSMap* args = vsapi->createMap();
vsapi->mapConsumeNode(args, "clipa", d->node, maAppend);
vsapi->mapSetInt(args, "plane", d->plane, maAppend);
vsapi->mapSetData(args, "prop", "PlaneStats", -1, dtUtf8, maAppend);
VSPlugin* stdplugin = vsapi->getPluginByID(VSH_STD_PLUGIN_ID, core);
VSMap* ret = vsapi->invoke(stdplugin, "PlaneStats", args);
d->node = vsapi->mapGetNode(ret, "clip", 0, nullptr);
vsapi->freeMap(args);
vsapi->freeMap(ret);
}

VSFilterDependency deps[] = { {d->node, rpStrictSpatial} };
vsapi->createVideoFilter(out, "PlaneMinMax", vi, planeMinMaxGetFrame, planeMinMaxFree, fmParallel, deps, 1, d.get(), core);
d.release();
Expand Down

0 comments on commit b91b1b9

Please sign in to comment.