From 10e1d8e8fa3d33aa52f4f5037630cd8eb4d4e4f0 Mon Sep 17 00:00:00 2001 From: Crend King <975235+CrendKing@users.noreply.github.com> Date: Fri, 23 Jul 2021 19:46:47 -0700 Subject: [PATCH] Create macro for AVS env --- avisynth_filter/src/format.cpp | 14 +++---- avisynth_filter/src/frameserver.h | 2 + vapoursynth_filter/src/format.cpp | 38 +++++++++--------- vapoursynth_filter/src/frame_handler.cpp | 50 ++++++++++++------------ vapoursynth_filter/src/frameserver.cpp | 40 +++++++++---------- vapoursynth_filter/src/frameserver.h | 2 +- 6 files changed, 74 insertions(+), 72 deletions(-) diff --git a/avisynth_filter/src/format.cpp b/avisynth_filter/src/format.cpp index 07ec361..45894b0 100644 --- a/avisynth_filter/src/format.cpp +++ b/avisynth_filter/src/format.cpp @@ -88,7 +88,7 @@ auto Format::WriteSample(const VideoFormat &videoFormat, const PVideoFrame &srcF } auto Format::CreateFrame(const VideoFormat &videoFormat, const BYTE *srcBuffer) -> PVideoFrame { - PVideoFrame frame = MainFrameServer::GetInstance().GetEnv()->NewVideoFrame(videoFormat.videoInfo, static_cast(_vectorSize)); + PVideoFrame frame = AVSF_AVS_API->NewVideoFrame(videoFormat.videoInfo, static_cast(_vectorSize)); const std::array dstSlices = { frame->GetWritePtr(), frame->GetWritePtr(PLANAR_U), frame->GetWritePtr(PLANAR_V) }; const std::array dstStrides = { frame->GetPitch(), frame->GetPitch(PLANAR_U), frame->GetPitch(PLANAR_V) }; @@ -113,7 +113,7 @@ auto Format::CopyFromInput(const VideoFormat &videoFormat, const BYTE *srcBuffer srcMainPlaneStride = -srcMainPlaneStride; } - MainFrameServer::GetInstance().GetEnv()->BitBlt(dstSlices[0], dstStrides[0], srcMainPlane, srcMainPlaneStride, rowSize, height); + AVSF_AVS_API->BitBlt(dstSlices[0], dstStrides[0], srcMainPlane, srcMainPlaneStride, rowSize, height); if (videoFormat.pixelFormat->frameServerFormatId & VideoInfo::CS_INTERLEAVED) { return; @@ -161,8 +161,8 @@ auto Format::CopyFromInput(const VideoFormat &videoFormat, const BYTE *srcBuffer srcV = srcUVPlane2; } - MainFrameServer::GetInstance().GetEnv()->BitBlt(dstSlices[1], dstStrides[1], srcU, srcUVStride, srcUVRowSize, srcUVHeight); - MainFrameServer::GetInstance().GetEnv()->BitBlt(dstSlices[2], dstStrides[2], srcV, srcUVStride, srcUVRowSize, srcUVHeight); + AVSF_AVS_API->BitBlt(dstSlices[1], dstStrides[1], srcU, srcUVStride, srcUVRowSize, srcUVHeight); + AVSF_AVS_API->BitBlt(dstSlices[2], dstStrides[2], srcV, srcUVStride, srcUVRowSize, srcUVHeight); } } @@ -179,7 +179,7 @@ auto Format::CopyToOutput(const VideoFormat &videoFormat, const std::arrayBitBlt(dstMainPlane, dstMainPlaneStride, srcSlices[0], srcStrides[0], rowSize, height); + AVSF_AVS_API->BitBlt(dstMainPlane, dstMainPlaneStride, srcSlices[0], srcStrides[0], rowSize, height); if (videoFormat.pixelFormat->frameServerFormatId & VideoInfo::CS_INTERLEAVED) { return; @@ -221,8 +221,8 @@ auto Format::CopyToOutput(const VideoFormat &videoFormat, const std::arrayBitBlt(dstU, dstUVStride, srcSlices[1], srcStrides[1], dstUVRowSize, dstUVHeight); - MainFrameServer::GetInstance().GetEnv()->BitBlt(dstV, dstUVStride, srcSlices[2], srcStrides[2], dstUVRowSize, dstUVHeight); + AVSF_AVS_API->BitBlt(dstU, dstUVStride, srcSlices[1], srcStrides[1], dstUVRowSize, dstUVHeight); + AVSF_AVS_API->BitBlt(dstV, dstUVStride, srcSlices[2], srcStrides[2], dstUVRowSize, dstUVHeight); } } diff --git a/avisynth_filter/src/frameserver.h b/avisynth_filter/src/frameserver.h index 659e721..b13b73f 100644 --- a/avisynth_filter/src/frameserver.h +++ b/avisynth_filter/src/frameserver.h @@ -86,4 +86,6 @@ class AuxFrameServer constexpr auto GetScriptPixelType() const -> int { return _scriptVideoInfo.pixel_type; } }; +#define AVSF_AVS_API MainFrameServer::GetInstance().GetEnv() + } diff --git a/vapoursynth_filter/src/format.cpp b/vapoursynth_filter/src/format.cpp index 7b385a8..126f72b 100644 --- a/vapoursynth_filter/src/format.cpp +++ b/vapoursynth_filter/src/format.cpp @@ -53,7 +53,7 @@ auto Format::GetVideoFormat(const AM_MEDIA_TYPE &mediaType, const FrameServerBas .frameServer = vsCore }; ret.videoInfo = { - .format = AVSF_VS_API->getFormatPreset(ret.pixelFormat->frameServerFormatId, ret.frameServer), + .format = AVSF_VPS_API->getFormatPreset(ret.pixelFormat->frameServerFormatId, ret.frameServer), .fpsNum = fpsNum, .fpsDen = fpsDen, .width = ret.bmi.biWidth, @@ -85,29 +85,29 @@ auto Format::GetVideoFormat(const AM_MEDIA_TYPE &mediaType, const FrameServerBas } auto Format::WriteSample(const VideoFormat &videoFormat, const VSFrameRef *srcFrame, BYTE *dstBuffer) -> void { - const std::array srcSlices = { AVSF_VS_API->getReadPtr(srcFrame, 0) - , videoFormat.videoInfo.format->numPlanes < 2 ? nullptr : AVSF_VS_API->getReadPtr(srcFrame, 1) - , videoFormat.videoInfo.format->numPlanes < 3 ? nullptr : AVSF_VS_API->getReadPtr(srcFrame, 2) }; - const std::array srcStrides = { AVSF_VS_API->getStride(srcFrame, 0) - , videoFormat.videoInfo.format->numPlanes < 2 ? 0 : AVSF_VS_API->getStride(srcFrame, 1) - , videoFormat.videoInfo.format->numPlanes < 3 ? 0 : AVSF_VS_API->getStride(srcFrame, 2) }; - const int rowSize = AVSF_VS_API->getFrameWidth(srcFrame, 0) * videoFormat.videoInfo.format->bytesPerSample; - - CopyToOutput(videoFormat, srcSlices, srcStrides, dstBuffer, rowSize, AVSF_VS_API->getFrameHeight(srcFrame, 0)); + const std::array srcSlices = { AVSF_VPS_API->getReadPtr(srcFrame, 0) + , videoFormat.videoInfo.format->numPlanes < 2 ? nullptr : AVSF_VPS_API->getReadPtr(srcFrame, 1) + , videoFormat.videoInfo.format->numPlanes < 3 ? nullptr : AVSF_VPS_API->getReadPtr(srcFrame, 2) }; + const std::array srcStrides = { AVSF_VPS_API->getStride(srcFrame, 0) + , videoFormat.videoInfo.format->numPlanes < 2 ? 0 : AVSF_VPS_API->getStride(srcFrame, 1) + , videoFormat.videoInfo.format->numPlanes < 3 ? 0 : AVSF_VPS_API->getStride(srcFrame, 2) }; + const int rowSize = AVSF_VPS_API->getFrameWidth(srcFrame, 0) * videoFormat.videoInfo.format->bytesPerSample; + + CopyToOutput(videoFormat, srcSlices, srcStrides, dstBuffer, rowSize, AVSF_VPS_API->getFrameHeight(srcFrame, 0)); } auto Format::CreateFrame(const VideoFormat &videoFormat, const BYTE *srcBuffer) -> VSFrameRef * { - VSFrameRef *frame = AVSF_VS_API->newVideoFrame(videoFormat.videoInfo.format, videoFormat.videoInfo.width, videoFormat.videoInfo.height, nullptr, videoFormat.frameServer); + VSFrameRef *frame = AVSF_VPS_API->newVideoFrame(videoFormat.videoInfo.format, videoFormat.videoInfo.width, videoFormat.videoInfo.height, nullptr, videoFormat.frameServer); - const std::array dstSlices = { AVSF_VS_API->getWritePtr(frame, 0) - , videoFormat.videoInfo.format->numPlanes < 2 ? nullptr : AVSF_VS_API->getWritePtr(frame, 1) - , videoFormat.videoInfo.format->numPlanes < 3 ? nullptr : AVSF_VS_API->getWritePtr(frame, 2) }; - const std::array dstStrides = { AVSF_VS_API->getStride(frame, 0) - , videoFormat.videoInfo.format->numPlanes < 2 ? 0 : AVSF_VS_API->getStride(frame, 1) - , videoFormat.videoInfo.format->numPlanes < 3 ? 0 : AVSF_VS_API->getStride(frame, 2) }; - const int rowSize = AVSF_VS_API->getFrameWidth(frame, 0) * videoFormat.videoInfo.format->bytesPerSample; + const std::array dstSlices = { AVSF_VPS_API->getWritePtr(frame, 0) + , videoFormat.videoInfo.format->numPlanes < 2 ? nullptr : AVSF_VPS_API->getWritePtr(frame, 1) + , videoFormat.videoInfo.format->numPlanes < 3 ? nullptr : AVSF_VPS_API->getWritePtr(frame, 2) }; + const std::array dstStrides = { AVSF_VPS_API->getStride(frame, 0) + , videoFormat.videoInfo.format->numPlanes < 2 ? 0 : AVSF_VPS_API->getStride(frame, 1) + , videoFormat.videoInfo.format->numPlanes < 3 ? 0 : AVSF_VPS_API->getStride(frame, 2) }; + const int rowSize = AVSF_VPS_API->getFrameWidth(frame, 0) * videoFormat.videoInfo.format->bytesPerSample; - CopyFromInput(videoFormat, srcBuffer, dstSlices, dstStrides, rowSize, AVSF_VS_API->getFrameHeight(frame, 0)); + CopyFromInput(videoFormat, srcBuffer, dstSlices, dstStrides, rowSize, AVSF_VPS_API->getFrameHeight(frame, 0)); return frame; } diff --git a/vapoursynth_filter/src/frame_handler.cpp b/vapoursynth_filter/src/frame_handler.cpp index e9a55f8..33f622c 100644 --- a/vapoursynth_filter/src/frame_handler.cpp +++ b/vapoursynth_filter/src/frame_handler.cpp @@ -70,18 +70,18 @@ auto FrameHandler::AddInputSample(IMediaSample *inputSample) -> HRESULT { } VSFrameRef *frame = Format::CreateFrame(_filter._inputVideoFormat, sampleBuffer); - VSMap *frameProps = AVSF_VS_API->getFramePropsRW(frame); - AVSF_VS_API->propSetFloat(frameProps, VS_PROP_NAME_ABS_TIME, inputSampleStartTime / static_cast(UNITS), paReplace); - AVSF_VS_API->propSetInt(frameProps, "_SARNum", _filter._inputVideoFormat.pixelAspectRatioNum, paReplace); - AVSF_VS_API->propSetInt(frameProps, "_SARDen", _filter._inputVideoFormat.pixelAspectRatioDen, paReplace); - AVSF_VS_API->propSetInt(frameProps, VS_PROP_NAME_SOURCE_FRAME_NB, _nextSourceFrameNb, paReplace); + VSMap *frameProps = AVSF_VPS_API->getFramePropsRW(frame); + AVSF_VPS_API->propSetFloat(frameProps, VS_PROP_NAME_ABS_TIME, inputSampleStartTime / static_cast(UNITS), paReplace); + AVSF_VPS_API->propSetInt(frameProps, "_SARNum", _filter._inputVideoFormat.pixelAspectRatioNum, paReplace); + AVSF_VPS_API->propSetInt(frameProps, "_SARDen", _filter._inputVideoFormat.pixelAspectRatioDen, paReplace); + AVSF_VPS_API->propSetInt(frameProps, VS_PROP_NAME_SOURCE_FRAME_NB, _nextSourceFrameNb, paReplace); if (const std::optional &optColorRange = _filter._inputVideoFormat.colorSpaceInfo.colorRange) { - AVSF_VS_API->propSetInt(frameProps, "_ColorRange", *optColorRange, paReplace); + AVSF_VPS_API->propSetInt(frameProps, "_ColorRange", *optColorRange, paReplace); } - AVSF_VS_API->propSetInt(frameProps, "_Primaries", _filter._inputVideoFormat.colorSpaceInfo.primaries, paReplace); - AVSF_VS_API->propSetInt(frameProps, "_Matrix", _filter._inputVideoFormat.colorSpaceInfo.matrix, paReplace); - AVSF_VS_API->propSetInt(frameProps, "_Transfer", _filter._inputVideoFormat.colorSpaceInfo.transfer, paReplace); + AVSF_VPS_API->propSetInt(frameProps, "_Primaries", _filter._inputVideoFormat.colorSpaceInfo.primaries, paReplace); + AVSF_VPS_API->propSetInt(frameProps, "_Matrix", _filter._inputVideoFormat.colorSpaceInfo.matrix, paReplace); + AVSF_VPS_API->propSetInt(frameProps, "_Transfer", _filter._inputVideoFormat.colorSpaceInfo.transfer, paReplace); std::unique_ptr hdrSideData = std::make_unique(); { @@ -142,12 +142,12 @@ auto FrameHandler::AddInputSample(IMediaSample *inputSample) -> HRESULT { } _nextProcessSourceFrameNb = processSourceFrameIters[1]->first; - frameProps = AVSF_VS_API->getFramePropsRW(processSourceFrameIters[0]->second.frame); + frameProps = AVSF_VPS_API->getFramePropsRW(processSourceFrameIters[0]->second.frame); REFERENCE_TIME frameDurationNum = processSourceFrameIters[1]->second.startTime - processSourceFrameIters[0]->second.startTime; REFERENCE_TIME frameDurationDen = UNITS; vs_normalizeRational(&frameDurationNum, &frameDurationDen); - AVSF_VS_API->propSetInt(frameProps, VS_PROP_NAME_DURATION_NUM, frameDurationNum, paReplace); - AVSF_VS_API->propSetInt(frameProps, VS_PROP_NAME_DURATION_DEN, frameDurationDen, paReplace); + AVSF_VPS_API->propSetInt(frameProps, VS_PROP_NAME_DURATION_NUM, frameDurationNum, paReplace); + AVSF_VPS_API->propSetInt(frameProps, VS_PROP_NAME_DURATION_DEN, frameDurationDen, paReplace); _newSourceFrameCv.notify_all(); const int maxRequestOutputFrameNb = static_cast(llMulDiv(processSourceFrameIters[0]->first, @@ -163,7 +163,7 @@ auto FrameHandler::AddInputSample(IMediaSample *inputSample) -> HRESULT { _outputFrames.emplace(_nextOutputFrameNb, nullptr); } - AVSF_VS_API->getFrameAsync(_nextOutputFrameNb, MainFrameServer::GetInstance().GetScriptClip(), VpsGetFrameCallback, this); + AVSF_VPS_API->getFrameAsync(_nextOutputFrameNb, MainFrameServer::GetInstance().GetScriptClip(), VpsGetFrameCallback, this); _nextOutputFrameNb += 1; } @@ -188,8 +188,8 @@ auto FrameHandler::GetSourceFrame(int frameNb) -> const VSFrameRef * { return false; } - const VSMap *frameProps = AVSF_VS_API->getFramePropsRO(iter->second.frame); - return AVSF_VS_API->propNumElements(frameProps, VS_PROP_NAME_DURATION_NUM) > 0 && AVSF_VS_API->propNumElements(frameProps, VS_PROP_NAME_DURATION_DEN) > 0; + const VSMap *frameProps = AVSF_VPS_API->getFramePropsRO(iter->second.frame); + return AVSF_VPS_API->propNumElements(frameProps, VS_PROP_NAME_DURATION_NUM) > 0 && AVSF_VPS_API->propNumElements(frameProps, VS_PROP_NAME_DURATION_DEN) > 0; }); if (_isFlushing) { @@ -243,7 +243,7 @@ auto FrameHandler::EndFlush(const std::function &interim) -> void { // only the current thread is active here, no need to lock for (const VSFrameRef *frame : _outputFrames | std::views::values) { - AVSF_VS_API->freeFrame(frame); + AVSF_VPS_API->freeFrame(frame); } _outputFrames.clear(); @@ -257,7 +257,7 @@ auto FrameHandler::EndFlush(const std::function &interim) -> void { } FrameHandler::SourceFrameInfo::~SourceFrameInfo() { - AVSF_VS_API->freeFrame(frame); + AVSF_VPS_API->freeFrame(frame); } auto VS_CC FrameHandler::VpsGetFrameCallback(void *userData, const VSFrameRef *f, int n, VSNodeRef *node, const char *errorMsg) -> void { @@ -277,7 +277,7 @@ auto VS_CC FrameHandler::VpsGetFrameCallback(void *userData, const VSFrameRef *f } frameHandler->_flushOutputSampleCv.notify_all(); - AVSF_VS_API->freeFrame(f); + AVSF_VPS_API->freeFrame(f); } else { { std::shared_lock sharedOutputLock(frameHandler->_outputMutex); @@ -300,10 +300,10 @@ auto FrameHandler::ResetInput() -> void { } auto FrameHandler::PrepareOutputSample(ATL::CComPtr &sample, int outputFrameNb, const VSFrameRef *outputFrame, int sourceFrameNb) -> bool { - const VSMap *frameProps = AVSF_VS_API->getFramePropsRO(outputFrame); + const VSMap *frameProps = AVSF_VPS_API->getFramePropsRO(outputFrame); int propGetError; - const int64_t frameDurationNum = AVSF_VS_API->propGetInt(frameProps, VS_PROP_NAME_DURATION_NUM, 0, &propGetError); - const int64_t frameDurationDen = AVSF_VS_API->propGetInt(frameProps, VS_PROP_NAME_DURATION_DEN, 0, &propGetError); + const int64_t frameDurationNum = AVSF_VPS_API->propGetInt(frameProps, VS_PROP_NAME_DURATION_NUM, 0, &propGetError); + const int64_t frameDurationDen = AVSF_VPS_API->propGetInt(frameProps, VS_PROP_NAME_DURATION_DEN, 0, &propGetError); int64_t frameDuration; if (frameDurationNum > 0 && frameDurationDen > 0) { @@ -313,7 +313,7 @@ auto FrameHandler::PrepareOutputSample(ATL::CComPtr &sample, int o } if (_nextOutputFrameStartTime == 0) { - _nextOutputFrameStartTime = static_cast(AVSF_VS_API->propGetFloat(frameProps, VS_PROP_NAME_ABS_TIME, 0, &propGetError) * UNITS); + _nextOutputFrameStartTime = static_cast(AVSF_VPS_API->propGetFloat(frameProps, VS_PROP_NAME_ABS_TIME, 0, &propGetError) * UNITS); } REFERENCE_TIME frameStartTime = _nextOutputFrameStartTime; @@ -437,9 +437,9 @@ auto FrameHandler::WorkerProc() -> void { continue; } - const VSMap *frameProps = AVSF_VS_API->getFramePropsRO(iter->second); + const VSMap *frameProps = AVSF_VPS_API->getFramePropsRO(iter->second); int propGetError; - const int sourceFrameNb = static_cast(AVSF_VS_API->propGetInt(frameProps, VS_PROP_NAME_SOURCE_FRAME_NB, 0, &propGetError)); + const int sourceFrameNb = static_cast(AVSF_VPS_API->propGetInt(frameProps, VS_PROP_NAME_SOURCE_FRAME_NB, 0, &propGetError)); _lastUsedSourceFrameNb = sourceFrameNb; _addInputSampleCv.notify_all(); @@ -454,7 +454,7 @@ auto FrameHandler::WorkerProc() -> void { { std::unique_lock uniqueOutputLock(_outputMutex); - AVSF_VS_API->freeFrame(iter->second); + AVSF_VPS_API->freeFrame(iter->second); _outputFrames.erase(iter); } diff --git a/vapoursynth_filter/src/frameserver.cpp b/vapoursynth_filter/src/frameserver.cpp index 5728410..59575bc 100644 --- a/vapoursynth_filter/src/frameserver.cpp +++ b/vapoursynth_filter/src/frameserver.cpp @@ -11,17 +11,17 @@ static constexpr const char *VPS_VAR_NAME_SOURCE_NODE = "VpsFilterSource"; static constexpr const char *VPS_VAR_NAME_DISCONNECT = "VpsFilterDisconnect"; static auto VS_CC SourceInit(VSMap *in, VSMap *out, void **instanceData, VSNode *node, VSCore *core, const VSAPI *vsapi) -> void { - AVSF_VS_API->setVideoInfo(&FrameServerCommon::GetInstance().GetSourceVideoInfo(), 1, node); + AVSF_VPS_API->setVideoInfo(&FrameServerCommon::GetInstance().GetSourceVideoInfo(), 1, node); } static auto VS_CC SourceGetFrame(int n, int activationReason, void **instanceData, void **frameData, VSFrameContext *frameCtx, VSCore *core, const VSAPI *vsapi) -> const VSFrameRef * { FrameHandler *frameHandler = FrameServerCommon::GetInstance().GetFrameHandler(); if (frameHandler == nullptr) { - AVSF_VS_API->setFilterError("VapourSynth Filter: Source frame is requested before the frame handler is ready", frameCtx); + AVSF_VPS_API->setFilterError("VapourSynth Filter: Source frame is requested before the frame handler is ready", frameCtx); return nullptr; } - return AVSF_VS_API->cloneFrameRef(frameHandler->GetSourceFrame(n)); + return AVSF_VPS_API->cloneFrameRef(frameHandler->GetSourceFrame(n)); } FrameServerCommon::FrameServerCommon() { @@ -67,7 +67,7 @@ auto FrameServerCommon::LinkFrameHandler(FrameHandler *frameHandler) -> void { auto FrameServerBase::StopScript() -> void { if (_scriptClip != nullptr) { Environment::GetInstance().Log(L"Release script clip: %p", _scriptClip); - AVSF_VS_API->freeNode(_scriptClip); + AVSF_VPS_API->freeNode(_scriptClip); _scriptClip = nullptr; } } @@ -89,16 +89,16 @@ auto FrameServerBase::ReloadScript(const AM_MEDIA_TYPE &mediaType, bool ignoreDi FrameServerCommon::GetInstance()._sourceVideoInfo = Format::GetVideoFormat(mediaType, this).videoInfo; - VSMap *filterInputs = AVSF_VS_API->createMap(); - VSMap *filterOutputs = AVSF_VS_API->createMap(); + VSMap *filterInputs = AVSF_VPS_API->createMap(); + VSMap *filterOutputs = AVSF_VPS_API->createMap(); - AVSF_VS_API->createFilter(filterInputs, filterOutputs, "VpsFilter_Source", SourceInit, SourceGetFrame, nullptr, fmParallel, nfNoCache, nullptr, vsscript_getCore(_vsScript)); - VSNodeRef *sourceClip = AVSF_VS_API->propGetNode(filterOutputs, "clip", 0, nullptr); - AVSF_VS_API->propSetNode(filterInputs, VPS_VAR_NAME_SOURCE_NODE, sourceClip, 0); + AVSF_VPS_API->createFilter(filterInputs, filterOutputs, "VpsFilter_Source", SourceInit, SourceGetFrame, nullptr, fmParallel, nfNoCache, nullptr, vsscript_getCore(_vsScript)); + VSNodeRef *sourceClip = AVSF_VPS_API->propGetNode(filterOutputs, "clip", 0, nullptr); + AVSF_VPS_API->propSetNode(filterInputs, VPS_VAR_NAME_SOURCE_NODE, sourceClip, 0); vsscript_setVariable(_vsScript, filterInputs); - AVSF_VS_API->freeMap(filterOutputs); - AVSF_VS_API->freeMap(filterInputs); + AVSF_VPS_API->freeMap(filterOutputs); + AVSF_VPS_API->freeMap(filterInputs); _errorString.clear(); @@ -110,12 +110,12 @@ auto FrameServerBase::ReloadScript(const AM_MEDIA_TYPE &mediaType, bool ignoreDi if (vsscript_evaluateFile(&_vsScript, utf8Filename.c_str(), efSetWorkingDir) == 0) { _scriptClip = vsscript_getOutput(_vsScript, 0); - VSMap *scriptOutputs = AVSF_VS_API->createMap(); + VSMap *scriptOutputs = AVSF_VPS_API->createMap(); vsscript_getVariable(_vsScript, VPS_VAR_NAME_DISCONNECT, scriptOutputs); - if (AVSF_VS_API->propNumElements(scriptOutputs, VPS_VAR_NAME_DISCONNECT) == 1) { - toDisconnect = AVSF_VS_API->propGetInt(scriptOutputs, VPS_VAR_NAME_DISCONNECT, 0, nullptr) != 0; + if (AVSF_VPS_API->propNumElements(scriptOutputs, VPS_VAR_NAME_DISCONNECT) == 1) { + toDisconnect = AVSF_VPS_API->propGetInt(scriptOutputs, VPS_VAR_NAME_DISCONNECT, 0, nullptr) != 0; } - AVSF_VS_API->freeMap(scriptOutputs); + AVSF_VPS_API->freeMap(scriptOutputs); } else { _errorString = vsscript_getError(_vsScript); } @@ -137,7 +137,7 @@ core.text.Text({}, r'''{}''').set_output()", VPS_VAR_NAME_SOURCE_NODE, _errorStr } if (sourceClip != _scriptClip) { - AVSF_VS_API->freeNode(sourceClip); + AVSF_VPS_API->freeNode(sourceClip); } if (toDisconnect && !ignoreDisconnect) { @@ -145,14 +145,14 @@ core.text.Text({}, r'''{}''').set_output()", VPS_VAR_NAME_SOURCE_NODE, _errorStr } Environment::GetInstance().Log(L"New script clip: %p", _scriptClip); - _scriptVideoInfo = *AVSF_VS_API->getVideoInfo(_scriptClip); + _scriptVideoInfo = *AVSF_VPS_API->getVideoInfo(_scriptClip); _scriptAvgFrameDuration = llMulDiv(_scriptVideoInfo.fpsDen, UNITS, _scriptVideoInfo.fpsNum, 0); return true; } MainFrameServer::~MainFrameServer() { - AVSF_VS_API->freeFrame(_sourceDrainFrame); + AVSF_VPS_API->freeFrame(_sourceDrainFrame); } auto MainFrameServer::ReloadScript(const AM_MEDIA_TYPE &mediaType, bool ignoreDisconnect) -> bool { @@ -163,8 +163,8 @@ auto MainFrameServer::ReloadScript(const AM_MEDIA_TYPE &mediaType, bool ignoreDi _sourceAvgFrameRate = static_cast(llMulDiv(sourceVideoInfo.fpsNum, FRAME_RATE_SCALE_FACTOR, sourceVideoInfo.fpsDen, 0)); _sourceAvgFrameDuration = llMulDiv(sourceVideoInfo.fpsDen, UNITS, sourceVideoInfo.fpsNum, 0); - AVSF_VS_API->freeFrame(_sourceDrainFrame); - _sourceDrainFrame = AVSF_VS_API->newVideoFrame(FrameServerCommon::GetInstance()._sourceVideoInfo.format, + AVSF_VPS_API->freeFrame(_sourceDrainFrame); + _sourceDrainFrame = AVSF_VPS_API->newVideoFrame(FrameServerCommon::GetInstance()._sourceVideoInfo.format, FrameServerCommon::GetInstance()._sourceVideoInfo.width, FrameServerCommon::GetInstance()._sourceVideoInfo.height, nullptr, vsscript_getCore(_vsScript)); diff --git a/vapoursynth_filter/src/frameserver.h b/vapoursynth_filter/src/frameserver.h index 3c54af8..56b3334 100644 --- a/vapoursynth_filter/src/frameserver.h +++ b/vapoursynth_filter/src/frameserver.h @@ -91,6 +91,6 @@ class AuxFrameServer constexpr auto GetScriptPixelType() const -> int { return _scriptVideoInfo.format->id; } }; -#define AVSF_VS_API FrameServerCommon::GetInstance().GetVsApi() +#define AVSF_VPS_API FrameServerCommon::GetInstance().GetVsApi() }