Skip to content

Commit 619d83b

Browse files
committed
Version 10 Feb 2022
1 parent 3c99e87 commit 619d83b

File tree

3 files changed

+202
-152
lines changed

3 files changed

+202
-152
lines changed

FQBlur.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,17 @@ typedef struct
6262
float* inBuf;
6363
fftwf_complex* outBuf;
6464

65-
}BlurData;
65+
}F2QBlurData;
6666
/*************************************************/
6767
template <typename finc>
68-
void blurPlane2D(BlurData* d, float* inBuf, fftwf_complex* outBuf, float* filter,
68+
void blurPlane2D(F2QBlurData* d, float* inBuf, fftwf_complex* outBuf, float* filter,
6969
fftwf_plan pf, fftwf_plan pinv, const finc* sp, finc* dp,
7070
int pitch, int height, int width, int bestY, int bestX, finc min, finc max);
7171
void positionBlurFilter(fftwf_complex* fout, float* Filter, int bestx, int besty);
7272
//---------------------------------------------------------------------------------
73-
static void VS_CC blurInit(VSMap *in, VSMap *out, void **instanceData, VSNode *node, VSCore *core, const VSAPI *vsapi)
73+
static void VS_CC f2qblurInit(VSMap *in, VSMap *out, void **instanceData, VSNode *node, VSCore *core, const VSAPI *vsapi)
7474
{
75-
BlurData *d = (BlurData *) * instanceData;
75+
F2QBlurData *d = (F2QBlurData *) * instanceData;
7676
vsapi->setVideoInfo(d->vi, 1, node);
7777

7878
const VSFormat *fi = d->vi->format;
@@ -194,7 +194,7 @@ static void VS_CC blurInit(VSMap *in, VSMap *out, void **instanceData, VSNode *n
194194
//--------------------------------------------------------------------------------------------
195195
void positionBlurFilter(fftwf_complex* fout, float* Filter, int bestx, int besty)
196196
{
197-
float scale = 1.0 / (bestx * besty);
197+
float scale = 1.0f / (bestx * besty);
198198

199199
// transfer to filter buffer including scaling and removing filtering
200200

@@ -211,7 +211,7 @@ void positionBlurFilter(fftwf_complex* fout, float* Filter, int bestx, int besty
211211
}
212212
//--------------------------------------------------------------------------------------
213213
template <typename finc>
214-
void blurPlane2D(BlurData * d, float * inBuf, fftwf_complex * outBuf, float * filter,
214+
void blurPlane2D(F2QBlurData * d, float * inBuf, fftwf_complex * outBuf, float * filter,
215215
fftwf_plan pf, fftwf_plan pinv, const finc* sp, finc* dp,
216216
int pitch, int height, int width, int bestY, int bestX, finc min, finc max )
217217
{
@@ -236,10 +236,10 @@ void blurPlane2D(BlurData * d, float * inBuf, fftwf_complex * outBuf, float * fi
236236
// upstream filters.
237237
// Once all frames are ready, the filter will be called with arAllFramesReady. It is now time to
238238
// do the actual processing.
239-
static const VSFrameRef *VS_CC blurGetFrame(int n, int activationReason, void **instanceData,
239+
static const VSFrameRef *VS_CC f2qblurGetFrame(int n, int activationReason, void **instanceData,
240240
void **frameData, VSFrameContext *frameCtx, VSCore *core, const VSAPI *vsapi)
241241
{
242-
BlurData *d = (BlurData *) * instanceData;
242+
F2QBlurData *d = (F2QBlurData *) * instanceData;
243243

244244
if (activationReason == arInitial)
245245
{
@@ -361,9 +361,9 @@ static const VSFrameRef *VS_CC blurGetFrame(int n, int activationReason, void **
361361
}
362362
//----------------------------------------------------------------
363363
// Free all allocated data on filter destruction
364-
static void VS_CC blurFree(void *instanceData, VSCore *core, const VSAPI *vsapi)
364+
static void VS_CC f2qblurFree(void *instanceData, VSCore *core, const VSAPI *vsapi)
365365
{
366-
BlurData *d = (BlurData *)instanceData;
366+
F2QBlurData *d = (F2QBlurData *)instanceData;
367367
if (d->FreqFilterUV != d->FreqFilter)
368368
d->fftwf_free(d->FreqFilterUV);
369369
d->fftwf_free(d->FreqFilter);
@@ -387,10 +387,10 @@ static void VS_CC blurFree(void *instanceData, VSCore *core, const VSAPI *vsapi)
387387

388388

389389
// This function is responsible for validating arguments and creating a new filter
390-
static void VS_CC blurCreate(const VSMap *in, VSMap *out, void *userData, VSCore *core, const VSAPI *vsapi)
390+
static void VS_CC f2qblurCreate(const VSMap *in, VSMap *out, void *userData, VSCore *core, const VSAPI *vsapi)
391391
{
392-
BlurData d;
393-
BlurData *data;
392+
F2QBlurData d;
393+
F2QBlurData *data;
394394
int err;
395395
int temp;
396396
// Get a clip reference from the input arguments. This must be freed later.
@@ -401,19 +401,19 @@ static void VS_CC blurCreate(const VSMap *in, VSMap *out, void *userData, VSCore
401401
// vi->format can be 0 if the input clip can change format midstream.
402402
if (!isConstantFormat(d.vi) )
403403
{
404-
vsapi->setError(out, "fqBlur: clip must have constant dimensions and in YUV or RGB or Grey format ");
404+
vsapi->setError(out, "F2QBlur: clip must have constant dimensions and in YUV or RGB or Grey format ");
405405
vsapi->freeNode(d.node);
406406
return;
407407
}
408408
if (d.vi->format->colorFamily != cmRGB && d.vi->format->colorFamily != cmYUV && d.vi->format->colorFamily != cmGray)
409409
{
410-
vsapi->setError(out, "fqBlur: RGB, YUV and Gray color formats only for input allowed ");
410+
vsapi->setError(out, "F2QBlur: RGB, YUV and Gray color formats only for input allowed ");
411411
vsapi->freeNode(d.node);
412412
return;
413413
}
414414
if (d.vi->format->sampleType == stFloat && d.vi->format->bitsPerSample == 16)
415415
{
416-
vsapi->setError(out, "fqBlur: Half float formats not allowed ");
416+
vsapi->setError(out, "F2QBlur: Half float formats not allowed ");
417417
vsapi->freeNode(d.node);
418418
return;
419419
}
@@ -424,7 +424,7 @@ static void VS_CC blurCreate(const VSMap *in, VSMap *out, void *userData, VSCore
424424
// strict checking because of what we wrote in the argument string, the only
425425
// reason this could fail is when the value wasn't set by the user.
426426
// And when it's not set we want it to default to enabled.
427-
temp = !!vsapi->propGetInt(in, "line", 0, &err);
427+
temp = !!int64ToIntS(vsapi->propGetInt(in, "line", 0, &err));
428428
if (err)
429429
{
430430
d.line = true;
@@ -433,7 +433,7 @@ static void VS_CC blurCreate(const VSMap *in, VSMap *out, void *userData, VSCore
433433
// Let's pretend the only allowed values are 1 or 0...
434434
if (temp < 0 || temp > 1)
435435
{
436-
vsapi->setError(out, "fqBlur: line must be 0 (for circular blur) 1(for linear blur) ");
436+
vsapi->setError(out, "F2QBlur: line must be 0 (for circular blur) 1(for linear blur) ");
437437
vsapi->freeNode(d.node);
438438
return;
439439
}
@@ -446,7 +446,7 @@ static void VS_CC blurCreate(const VSMap *in, VSMap *out, void *userData, VSCore
446446
}
447447

448448

449-
d.xcoord = vsapi->propGetInt(in, "x", 0, &err);
449+
d.xcoord = int64ToIntS(vsapi->propGetInt(in, "x", 0, &err));
450450
if (err)
451451
{
452452
d.xcoord = 2;
@@ -455,12 +455,12 @@ static void VS_CC blurCreate(const VSMap *in, VSMap *out, void *userData, VSCore
455455
// the only allowed values are
456456
if ( (d.line && d.xcoord < 0) || d.xcoord > d.vi->width / 8 || ( !d.line && d.xcoord < 1))
457457
{
458-
vsapi->setError(out, "fqBlur: x coordinate can have a value from 0 for line and 1 for circular blur to 1/8th frame width only ");
458+
vsapi->setError(out, "F2QBlur: x coordinate can have a value from 0 for line and 1 for circular blur to 1/8th frame width only ");
459459
vsapi->freeNode(d.node);
460460
return;
461461
}
462462

463-
d.ycoord = vsapi->propGetInt(in, "y", 0, &err);
463+
d.ycoord = int64ToIntS(vsapi->propGetInt(in, "y", 0, &err));
464464
if (err)
465465
{
466466
d.ycoord = 2;
@@ -469,20 +469,20 @@ static void VS_CC blurCreate(const VSMap *in, VSMap *out, void *userData, VSCore
469469
// the only allowed values are
470470
if ( d.ycoord < - d.vi->height / 8 || d.ycoord > d.vi->height / 8)
471471
{
472-
vsapi->setError(out, "fqBlur: y coordinate can have a value between plus and minus 1/8th frame height only ");
472+
vsapi->setError(out, "F2QBlur: y coordinate can have a value between plus and minus 1/8th frame height only ");
473473
vsapi->freeNode(d.node);
474474
return;
475475
}
476476
if ( d.xcoord == 0 && d.ycoord == 0)
477477
{
478-
vsapi->setError(out, "fqBlur: both x and y coordinate must not be zeroes ");
478+
vsapi->setError(out, "F2QBlur: both x and y coordinate must not be zeroes ");
479479
vsapi->freeNode(d.node);
480480
return;
481481
}
482482

483483
// I usually keep the filter data struct on the stack and don't allocate it
484484
// until all the input validation is done.
485-
data = (BlurData*)malloc(sizeof(d));
485+
data = (F2QBlurData*)malloc(sizeof(d));
486486
*data = d;
487487

488488
// Creates a new filter and returns a reference to it. Always pass on the in and out
@@ -500,7 +500,7 @@ static void VS_CC blurCreate(const VSMap *in, VSMap *out, void *userData, VSCore
500500
// If your filter is really fast (such as a filter that only resorts frames) you should set the
501501
// nfNoCache flag to make the caching work smoother.
502502

503-
vsapi->createFilter(in, out, "fqBlur", blurInit, blurGetFrame, blurFree, fmParallelRequests, 0, data, core);
503+
vsapi->createFilter(in, out, "F2QBlur", f2qblurInit, f2qblurGetFrame, f2qblurFree, fmParallelRequests, 0, data, core);
504504

505505
}
506506
/*

FisheyePart.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ static const VSFrameRef* VS_CC fisheyepartGetFrame(int n, int activationReason,
329329
else
330330
//bilinear 2x2 or cubic 4x4 or lanczos 6x6
331331
*(dp + h * dpitch + w) = clamp(LaQuantile(sp + y * spitch + x, spitch,
332-
qx, qy, d->span, d->iCoeff), min8, max8);
332+
d->span,qx, qy, d->iCoeff), min8, max8);
333333

334334
}
335335

@@ -340,7 +340,7 @@ static const VSFrameRef* VS_CC fisheyepartGetFrame(int n, int activationReason,
340340
else
341341

342342
*((uint16_t*)dp + h * dpitch + w) = clamp(LaQuantile((uint16_t*)sp + y * spitch + x, spitch,
343-
qx, qy, d->span, d->iCoeff), min16, max16);
343+
d->span,qx, qy, d->iCoeff), min16, max16);
344344

345345
}
346346

@@ -351,7 +351,7 @@ static const VSFrameRef* VS_CC fisheyepartGetFrame(int n, int activationReason,
351351
else
352352

353353
*((float*)dp + h * dpitch + w) = clamp(LaQuantile((float*)sp + y * spitch + x, spitch,
354-
qx, qy, d->span, d->iCoeff), minf, maxf);
354+
d->span,qx, qy, d->iCoeff), minf, maxf);
355355

356356
}
357357
}

0 commit comments

Comments
 (0)