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

Commit

Permalink
Rename PlaneStatsMod filter to PlaneMinMax
Browse files Browse the repository at this point in the history
  • Loading branch information
dnjulek committed Jul 29, 2022
1 parent 3c3ed1a commit 915ea02
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/PlaneStatsMod.cpp → src/PlaneMinMax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
#include "VapourSynth4.h"
#include "VSHelper4.h"

struct PlaneStatsModData final {
struct planeMinMaxData final {
VSNode* node;
float minthr;
float maxthr;
int plane;
};

static const VSFrame* VS_CC planeStatsModGetFrame(int n, int activationReason, void* instanceData, void** frameData, VSFrameContext* frameCtx, VSCore* core, const VSAPI* vsapi) {
auto d{ static_cast<PlaneStatsModData*>(instanceData) };
static const VSFrame* VS_CC planeMinMaxGetFrame(int n, int activationReason, void* instanceData, void** frameData, VSFrameContext* frameCtx, VSCore* core, const VSAPI* vsapi) {
auto d{ static_cast<planeMinMaxData*>(instanceData) };

if (activationReason == arInitial) {
vsapi->requestFrameFilter(n, d->node, frameCtx);
Expand Down Expand Up @@ -117,14 +117,14 @@ static const VSFrame* VS_CC planeStatsModGetFrame(int n, int activationReason, v
return nullptr;
}

static void VS_CC planeStatsModFree(void* instanceData, [[maybe_unused]] VSCore* core, const VSAPI* vsapi) {
auto d{ static_cast<PlaneStatsModData*>(instanceData) };
static void VS_CC planeMinMaxFree(void* instanceData, [[maybe_unused]] VSCore* core, const VSAPI* vsapi) {
auto d{ static_cast<planeMinMaxData*>(instanceData) };
vsapi->freeNode(d->node);
delete d;
}

static void VS_CC planeStatsModCreate(const VSMap* in, VSMap* out, [[maybe_unused]] void* userData, VSCore* core, const VSAPI* vsapi) {
auto d{ std::make_unique<PlaneStatsModData>() };
static void VS_CC planeMinMaxCreate(const VSMap* in, VSMap* out, [[maybe_unused]] void* userData, VSCore* core, const VSAPI* vsapi) {
auto d{ std::make_unique<planeMinMaxData>() };
int err = 0;

d->node = vsapi->mapGetNode(in, "clip", 0, nullptr);
Expand All @@ -143,19 +143,19 @@ static void VS_CC planeStatsModCreate(const VSMap* in, VSMap* out, [[maybe_unuse
d->plane = 0;

if (d->plane < 0 || d->plane >= vi->format.numPlanes) {
vsapi->mapSetError(out, "PlaneStatsMod: invalid plane specified");
vsapi->mapSetError(out, "PlaneMinMax: invalid plane specified");
vsapi->freeNode(d->node);
return;
}

if (d->minthr < 0 || d->minthr > 1) {
vsapi->mapSetError(out, "PlaneStatsMod: minthr should be a float between 0.0 and 1.0");
vsapi->mapSetError(out, "PlaneMinMax: minthr should be a float between 0.0 and 1.0");
vsapi->freeNode(d->node);
return;
}

if (d->maxthr < 0 || d->maxthr > 1) {
vsapi->mapSetError(out, "PlaneStatsMod: maxthr should be a float between 0.0 and 1.0");
vsapi->mapSetError(out, "PlaneMinMax: maxthr should be a float between 0.0 and 1.0");
vsapi->freeNode(d->node);
return;
}
Expand All @@ -173,17 +173,17 @@ static void VS_CC planeStatsModCreate(const VSMap* in, VSMap* out, [[maybe_unuse
}

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

VS_EXTERNAL_API(void) VapourSynthPluginInit2(VSPlugin* plugin, const VSPLUGINAPI* vspapi) {
vspapi->configPlugin("com.julek.psm", "psm", "PlaneStats with threshold", VS_MAKE_VERSION(1, 0), VAPOURSYNTH_API_VERSION, 0, plugin);
vspapi->registerFunction("PlaneStatsMod",
vspapi->registerFunction("PlaneMinMax",
"clip:vnode;"
"minthr:float:opt;"
"maxthr:float:opt;"
"plane:int:opt;",
"clip:vnode;",
planeStatsModCreate, nullptr, plugin);
planeMinMaxCreate, nullptr, plugin);
}

0 comments on commit 915ea02

Please sign in to comment.