static const VSFrameRef *VS_CC mvsuperGetFrame(int32_t n, int32_t activationReason, void **instanceData, void **frameData, VSFrameContext *frameCtx, VSCore *core, const VSAPI *vsapi) { MVSuperData *d = reinterpret_cast<MVSuperData *>(*instanceData); if (activationReason == arInitial) { vsapi->requestFrameFilter(n, d->node, frameCtx); if (d->usePelClip) vsapi->requestFrameFilter(n, d->pelclip, frameCtx); } else if (activationReason == arAllFramesReady) { const VSFrameRef *src = vsapi->getFrameFilter(n, d->node, frameCtx); const uint8_t *pSrc[3] = { nullptr }; uint8_t *pDst[3] = { nullptr }; const uint8_t *pSrcPel[3] = { nullptr }; int32_t nSrcPitch[3] = { 0 }; int32_t nDstPitch[3] = { 0 }; int32_t nSrcPelPitch[3] = { 0 }; const VSFrameRef *srcPel = nullptr; if (d->usePelClip) srcPel = vsapi->getFrameFilter(n, d->pelclip, frameCtx); VSFrameRef *dst = vsapi->newVideoFrame(d->vi.format, d->vi.width, d->vi.height, src, core); for (int32_t plane = 0; plane < d->vi.format->numPlanes; ++plane) { pSrc[plane] = vsapi->getReadPtr(src, plane); nSrcPitch[plane] = vsapi->getStride(src, plane); pDst[plane] = vsapi->getWritePtr(dst, plane); nDstPitch[plane] = vsapi->getStride(dst, plane); memset(pDst[plane], 0, nDstPitch[plane] * vsapi->getFrameHeight(dst, plane)); } MVGroupOfFrames *pSrcGOF = new MVGroupOfFrames(d->nLevels, d->nWidth, d->nHeight, d->nPel, d->nHPad, d->nVPad, d->nModeYUV, d->xRatioUV, d->yRatioUV); pSrcGOF->Update(d->nModeYUV, pDst[0], nDstPitch[0], pDst[1], nDstPitch[1], pDst[2], nDstPitch[2]); MVPlaneSet planes[3] = { YPLANE, UPLANE, VPLANE }; for (int32_t plane = 0; plane < d->vi.format->numPlanes; ++plane) pSrcGOF->SetPlane(pSrc[plane], nSrcPitch[plane], planes[plane]); pSrcGOF->Reduce(d->nModeYUV, d->rfilter); pSrcGOF->Pad(d->nModeYUV); if (d->usePelClip) { MVFrame *srcFrames = pSrcGOF->GetFrame(0); for (int32_t plane = 0; plane < d->vi.format->numPlanes; ++plane) { pSrcPel[plane] = vsapi->getReadPtr(srcPel, plane); nSrcPelPitch[plane] = vsapi->getStride(srcPel, plane); MVPlane *srcPlane = srcFrames->GetPlane(planes[plane]); if (d->nModeYUV & planes[plane]) srcPlane->RefineExt(pSrcPel[plane], nSrcPelPitch[plane], d->isPelClipPadded); } } else pSrcGOF->Refine(d->nModeYUV, d->sharp); vsapi->freeFrame(src); if (d->usePelClip) vsapi->freeFrame(srcPel); delete pSrcGOF; if (n == 0) { VSMap *props = vsapi->getFramePropsRW(dst); vsapi->propSetInt(props, "Super_height", d->nHeight, paReplace); vsapi->propSetInt(props, "Super_hpad", d->nHPad, paReplace); vsapi->propSetInt(props, "Super_vpad", d->nVPad, paReplace); vsapi->propSetInt(props, "Super_pel", d->nPel, paReplace); vsapi->propSetInt(props, "Super_modeyuv", d->nModeYUV, paReplace); vsapi->propSetInt(props, "Super_levels", d->nLevels, paReplace); } return dst; } return nullptr; }