Skip to content

Commit

Permalink
r2
Browse files Browse the repository at this point in the history
  • Loading branch information
IFeelBloated committed Jun 5, 2016
1 parent cf05d04 commit 9280062
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 29 deletions.
6 changes: 3 additions & 3 deletions src/MVAnalyze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static const VSFrameRef *VS_CC mvanalyzeGetFrame(int32_t n, int32_t activationRe
return nullptr;
}
if (d->tffexists)
srctff = d->tff && (n % 2 == 0);
srctff = !!(static_cast<int>(d->tff) ^ (n % 2));
for (int32_t plane = 0; plane < d->supervi->format->numPlanes; plane++) {
pSrc[plane] = vsapi->getReadPtr(src, plane);
nSrcPitch[plane] = vsapi->getStride(src, plane);
Expand Down Expand Up @@ -148,7 +148,7 @@ static const VSFrameRef *VS_CC mvanalyzeGetFrame(int32_t n, int32_t activationRe
return nullptr;
}
if (d->tffexists)
reftff = d->tff && (nref % 2 == 0);
reftff = !!(static_cast<int>(d->tff) ^ (nref % 2));
int32_t fieldShift = 0;
if (d->fields && d->analysisData.nPel > 1 && (d->analysisData.nDeltaFrame % 2))
fieldShift = (srctff && !reftff) ? d->analysisData.nPel / 2 : ((reftff && !srctff) ? -(d->analysisData.nPel / 2) : 0);
Expand Down Expand Up @@ -257,7 +257,7 @@ static void VS_CC mvanalyzeCreate(const VSMap *in, VSMap *out, void *userData, V
d.tryMany = !!vsapi->propGetInt(in, "trymany", 0, &err);
d.fields = !!vsapi->propGetInt(in, "fields", 0, &err);
d.tff = !!vsapi->propGetInt(in, "tff", 0, &err);
d.tffexists = err;
d.tffexists = !err;
if (d.search < 0 || d.search > 7) {
vsapi->setError(out, "Analyze: search must be between 0 and 7 (inclusive).");
return;
Expand Down
24 changes: 13 additions & 11 deletions src/MVBlockFPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
struct MVBlockFPSData {
VSNodeRef *node;
VSVideoInfo vi;
const VSVideoInfo *oldvi;
const VSVideoInfo *supervi;
VSNodeRef *super;
VSNodeRef *mvbw;
Expand Down Expand Up @@ -242,23 +243,23 @@ static const VSFrameRef *VS_CC mvblockfpsGetFrame(int32_t n, int32_t activationR
if (off > 1)
time256 = time256 / off;
if (time256 == 0) {
vsapi->requestFrameFilter(d->vi.numFrames ? VSMIN(nleft, d->vi.numFrames - 1) : nleft, d->node, frameCtx);
vsapi->requestFrameFilter(d->vi.numFrames ? VSMIN(nleft, d->oldvi->numFrames - 1) : nleft, d->node, frameCtx);
return 0;
}
else if (time256 == 256) {
vsapi->requestFrameFilter(d->vi.numFrames ? VSMIN(nright, d->vi.numFrames - 1) : nright, d->node, frameCtx);
vsapi->requestFrameFilter(d->vi.numFrames ? VSMIN(nright, d->oldvi->numFrames - 1) : nright, d->node, frameCtx);
return 0;
}
if ((nleft < d->vi.numFrames && nright < d->vi.numFrames) || !d->vi.numFrames) {
if ((nleft < d->oldvi->numFrames && nright < d->vi.numFrames) || !d->oldvi->numFrames) {
vsapi->requestFrameFilter(nright, d->mvfw, frameCtx);
vsapi->requestFrameFilter(nleft, d->mvbw, frameCtx);

vsapi->requestFrameFilter(nleft, d->super, frameCtx);
vsapi->requestFrameFilter(nright, d->super, frameCtx);
}
vsapi->requestFrameFilter(d->vi.numFrames ? VSMIN(nleft, d->vi.numFrames - 1) : nleft, d->node, frameCtx);
vsapi->requestFrameFilter(d->vi.numFrames ? VSMIN(nleft, d->oldvi->numFrames - 1) : nleft, d->node, frameCtx);
if (d->blend)
vsapi->requestFrameFilter(d->vi.numFrames ? VSMIN(nright, d->vi.numFrames - 1) : nright, d->node, frameCtx);
vsapi->requestFrameFilter(d->vi.numFrames ? VSMIN(nright, d->oldvi->numFrames - 1) : nright, d->node, frameCtx);

}
else if (activationReason == arAllFramesReady) {
Expand All @@ -269,14 +270,14 @@ static const VSFrameRef *VS_CC mvblockfpsGetFrame(int32_t n, int32_t activationR
time256 = time256 / off;
int32_t nright = nleft + off;
if (time256 == 0)
return vsapi->getFrameFilter(d->vi.numFrames ? VSMIN(nleft, d->vi.numFrames - 1) : nleft, d->node, frameCtx);
return vsapi->getFrameFilter(d->vi.numFrames ? VSMIN(nleft, d->oldvi->numFrames - 1) : nleft, d->node, frameCtx);
else if (time256 == 256)
return vsapi->getFrameFilter(d->vi.numFrames ? VSMIN(nright, d->vi.numFrames - 1) : nright, d->node, frameCtx);
return vsapi->getFrameFilter(d->vi.numFrames ? VSMIN(nright, d->oldvi->numFrames - 1) : nright, d->node, frameCtx);
MVClipBalls ballsF(d->mvClipF, vsapi);
MVClipBalls ballsB(d->mvClipB, vsapi);
bool isUsableF = false;
bool isUsableB = false;
if ((nleft < d->vi.numFrames && nright < d->vi.numFrames) || !d->vi.numFrames) {
if ((nleft < d->oldvi->numFrames && nright < d->oldvi->numFrames) || !d->vi.numFrames) {
const VSFrameRef *mvF = vsapi->getFrameFilter(nright, d->mvfw, frameCtx);
ballsF.Update(mvF);
isUsableF = ballsF.IsUsable();
Expand Down Expand Up @@ -511,12 +512,12 @@ static const VSFrameRef *VS_CC mvblockfpsGetFrame(int32_t n, int32_t activationR
return dst;
}
else {
const VSFrameRef *src = vsapi->getFrameFilter(d->vi.numFrames ? VSMIN(nleft, d->vi.numFrames - 1) : nleft, d->node, frameCtx);
const VSFrameRef *src = vsapi->getFrameFilter(d->vi.numFrames ? VSMIN(nleft, d->oldvi->numFrames - 1) : nleft, d->node, frameCtx);
if (blend) {
uint8_t *pDst[3];
const uint8_t *pRef[3], *pSrc[3];
int32_t nDstPitches[3], nRefPitches[3], nSrcPitches[3];
const VSFrameRef *ref = vsapi->getFrameFilter(d->vi.numFrames ? VSMIN(nright, d->vi.numFrames - 1) : nright, d->node, frameCtx);
const VSFrameRef *ref = vsapi->getFrameFilter(d->vi.numFrames ? VSMIN(nright, d->oldvi->numFrames - 1) : nright, d->node, frameCtx);
VSFrameRef *dst = vsapi->newVideoFrame(d->vi.format, d->vi.width, d->vi.height, src, core);
for (int32_t i = 0; i < d->vi.format->numPlanes; i++) {
pDst[i] = vsapi->getWritePtr(dst, i);
Expand Down Expand Up @@ -733,7 +734,8 @@ static void VS_CC mvblockfpsCreate(const VSMap *in, VSMap *out, void *userData,
return;
}
d.node = vsapi->propGetNode(in, "clip", 0, 0);
d.vi = *vsapi->getVideoInfo(d.node);
d.oldvi = vsapi->getVideoInfo(d.node);
d.vi = *d.oldvi;
if (d.vi.fpsNum == 0 || d.vi.fpsDen == 0) {
vsapi->setError(out, "BlockFPS: The input clip must have a frame rate. Invoke AssumeFPS if necessary.");
vsapi->freeNode(d.super);
Expand Down
6 changes: 5 additions & 1 deletion src/MVCompensate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ static const VSFrameRef *VS_CC mvcompensateGetFrame(int32_t n, int32_t activatio
vsapi->freeFrame(ref);
return nullptr;
}
if (d->tffexists)
paritySrc = !!(static_cast<int>(d->tff) ^ (n % 2));
props = vsapi->getFramePropsRO(ref);
bool parityRef = !!vsapi->propGetInt(props, "_Field", 0, &err);
if (err && !d->tffexists) {
Expand All @@ -156,6 +158,8 @@ static const VSFrameRef *VS_CC mvcompensateGetFrame(int32_t n, int32_t activatio
vsapi->freeFrame(ref);
return nullptr;
}
if (d->tffexists)
parityRef = !!(static_cast<int>(d->tff) ^ (nref % 2));
fieldShift = (paritySrc && !parityRef) ? nPel / 2 : ((parityRef && !paritySrc) ? -(nPel / 2) : 0);
}
if (nOverlapX == 0 && nOverlapY == 0) {
Expand Down Expand Up @@ -412,7 +416,7 @@ static void VS_CC mvcompensateCreate(const VSMap *in, VSMap *out, void *userData
if (err)
d.nSCD2 = MV_DEFAULT_SCD2;
d.tff = !!vsapi->propGetInt(in, "tff", 0, &err);
d.tffexists = err;
d.tffexists = !err;
d.super = vsapi->propGetNode(in, "super", 0, nullptr);
char errorMsg[1024];
const VSFrameRef *evil = vsapi->getFrame(0, d.super, errorMsg, 1024);
Expand Down
24 changes: 13 additions & 11 deletions src/MVFlowFPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
struct MVFlowFPSData {
VSNodeRef *node;
VSVideoInfo vi;
const VSVideoInfo *oldvi;
VSNodeRef *finest;
VSNodeRef *super;
VSNodeRef *mvbw;
Expand Down Expand Up @@ -101,15 +102,15 @@ static const VSFrameRef *VS_CC mvflowfpsGetFrame(int32_t n, int32_t activationRe
time256 = time256 / off;

if (time256 == 0) {
vsapi->requestFrameFilter(d->vi.numFrames ? VSMIN(nleft, d->vi.numFrames - 1) : nleft, d->node, frameCtx);
vsapi->requestFrameFilter(d->vi.numFrames ? VSMIN(nleft, d->oldvi->numFrames - 1) : nleft, d->node, frameCtx);
return 0;
}
else if (time256 == 256) {
vsapi->requestFrameFilter(d->vi.numFrames ? VSMIN(nright, d->vi.numFrames - 1) : nright, d->node, frameCtx);
vsapi->requestFrameFilter(d->vi.numFrames ? VSMIN(nright, d->oldvi->numFrames - 1) : nright, d->node, frameCtx);
return 0;
}

if ((nleft < d->vi.numFrames && nright < d->vi.numFrames) || !d->vi.numFrames) { // for the good estimation case
if ((nleft < d->oldvi->numFrames && nright < d->oldvi->numFrames) || !d->vi.numFrames) { // for the good estimation case
if (d->maskmode == 2)
vsapi->requestFrameFilter(nleft, d->mvfw, frameCtx); // requests nleft - off, nleft
vsapi->requestFrameFilter(nright, d->mvfw, frameCtx); // requests nleft, nleft + off
Expand All @@ -121,10 +122,10 @@ static const VSFrameRef *VS_CC mvflowfpsGetFrame(int32_t n, int32_t activationRe
vsapi->requestFrameFilter(nright, d->finest, frameCtx);
}

vsapi->requestFrameFilter(d->vi.numFrames ? VSMIN(nleft, d->vi.numFrames - 1) : nleft, d->node, frameCtx);
vsapi->requestFrameFilter(d->vi.numFrames ? VSMIN(nleft, d->oldvi->numFrames - 1) : nleft, d->node, frameCtx);

if (d->blend)
vsapi->requestFrameFilter(d->vi.numFrames ? VSMIN(nright, d->vi.numFrames - 1) : nright, d->node, frameCtx);
vsapi->requestFrameFilter(d->vi.numFrames ? VSMIN(nright, d->oldvi->numFrames - 1) : nright, d->node, frameCtx);

}
else if (activationReason == arAllFramesReady) {
Expand All @@ -140,10 +141,10 @@ static const VSFrameRef *VS_CC mvflowfpsGetFrame(int32_t n, int32_t activationRe
int32_t nright = nleft + off;

if (time256 == 0) {
return vsapi->getFrameFilter(d->vi.numFrames ? VSMIN(nleft, d->vi.numFrames - 1) : nleft, d->node, frameCtx); // simply left
return vsapi->getFrameFilter(d->vi.numFrames ? VSMIN(nleft, d->oldvi->numFrames - 1) : nleft, d->node, frameCtx); // simply left
}
else if (time256 == 256) {
return vsapi->getFrameFilter(d->vi.numFrames ? VSMIN(nright, d->vi.numFrames - 1) : nright, d->node, frameCtx); // simply right
return vsapi->getFrameFilter(d->vi.numFrames ? VSMIN(nright, d->oldvi->numFrames - 1) : nright, d->node, frameCtx); // simply right
}

MVClipBalls ballsF(d->mvClipF, vsapi);
Expand All @@ -152,7 +153,7 @@ static const VSFrameRef *VS_CC mvflowfpsGetFrame(int32_t n, int32_t activationRe
bool isUsableF = false;
bool isUsableB = false;

if ((nleft < d->vi.numFrames && nright < d->vi.numFrames) || !d->vi.numFrames) {
if ((nleft < d->oldvi->numFrames && nright < d->oldvi->numFrames) || !d->vi.numFrames) {
const VSFrameRef *mvF = vsapi->getFrameFilter(nright, d->mvfw, frameCtx);
ballsF.Update(mvF);// forward from current to next
isUsableF = ballsF.IsUsable();
Expand Down Expand Up @@ -449,14 +450,14 @@ static const VSFrameRef *VS_CC mvflowfpsGetFrame(int32_t n, int32_t activationRe
return dst;
}
else { // poor estimation
const VSFrameRef *src = vsapi->getFrameFilter(d->vi.numFrames ? VSMIN(nleft, d->vi.numFrames - 1) : nleft, d->node, frameCtx);
const VSFrameRef *src = vsapi->getFrameFilter(d->vi.numFrames ? VSMIN(nleft, d->oldvi->numFrames - 1) : nleft, d->node, frameCtx);

if (blend) {//let's blend src with ref frames like ConvertFPS
uint8_t *pDst[3];
const uint8_t *pRef[3], *pSrc[3];
int32_t nDstPitches[3], nRefPitches[3], nSrcPitches[3];

const VSFrameRef *ref = vsapi->getFrameFilter(d->vi.numFrames ? VSMIN(nright, d->vi.numFrames - 1) : nright, d->node, frameCtx);
const VSFrameRef *ref = vsapi->getFrameFilter(d->vi.numFrames ? VSMIN(nright, d->oldvi->numFrames - 1) : nright, d->node, frameCtx);

VSFrameRef *dst = vsapi->newVideoFrame(d->vi.format, d->vi.width, d->vi.height, src, core);

Expand Down Expand Up @@ -784,7 +785,8 @@ static void VS_CC mvflowfpsCreate(const VSMap *in, VSMap *out, void *userData, V
}

d.node = vsapi->propGetNode(in, "clip", 0, 0);
d.vi = *vsapi->getVideoInfo(d.node);
d.oldvi = vsapi->getVideoInfo(d.node);
d.vi = *d.oldvi;


if (d.vi.fpsNum == 0 || d.vi.fpsDen == 0) {
Expand Down
6 changes: 3 additions & 3 deletions src/MVRecalculate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static const VSFrameRef *VS_CC mvrecalculateGetFrame(int32_t n, int32_t activati
return nullptr;
}
if (d->tffexists)
srctff = d->tff && (n % 2 == 0);
srctff = !!(static_cast<int>(d->tff) ^ (n % 2));
for (int32_t plane = 0; plane < d->supervi->format->numPlanes; plane++) {
pSrc[plane] = vsapi->getReadPtr(src, plane);
nSrcPitch[plane] = vsapi->getStride(src, plane);
Expand Down Expand Up @@ -124,7 +124,7 @@ static const VSFrameRef *VS_CC mvrecalculateGetFrame(int32_t n, int32_t activati
return nullptr;
}
if (d->tffexists)
reftff = d->tff && (nref % 2 == 0);
reftff = !!(static_cast<int>(d->tff) ^ (nref % 2));
int32_t fieldShift = 0;
if (d->fields && d->analysisData.nPel > 1 && (d->analysisData.nDeltaFrame % 2)) {
fieldShift = (srctff && !reftff) ? d->analysisData.nPel / 2 : ((reftff && !srctff) ? -(d->analysisData.nPel / 2) : 0);
Expand Down Expand Up @@ -215,7 +215,7 @@ static void VS_CC mvrecalculateCreate(const VSMap *in, VSMap *out, void *userDat
d.meander = 1;
d.fields = !!vsapi->propGetInt(in, "fields", 0, &err);
d.tff = !!vsapi->propGetInt(in, "tff", 0, &err);
d.tffexists = err;
d.tffexists = !err;
if (d.search < 0 || d.search > 7) {
vsapi->setError(out, "Recalculate: search must be between 0 and 7 (inclusive).");
return;
Expand Down

0 comments on commit 9280062

Please sign in to comment.