-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/build | ||
/out | ||
CMakePresets.json | ||
/.vs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
cmake_minimum_required (VERSION 3.8) | ||
|
||
# Enable Hot Reload for MSVC compilers if supported. | ||
if (POLICY CMP0141) | ||
cmake_policy(SET CMP0141 NEW) | ||
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>") | ||
endif() | ||
|
||
project ("vs-misc-tomcup") | ||
|
||
set(VapourSynthSDK "C:/Users/jilig/Downloads/upscale/VapourSynth/sdk") | ||
|
||
add_library(${PROJECT_NAME} SHARED "vs-misc-tomcup.cpp" ) | ||
|
||
add_subdirectory(csv-parser) | ||
|
||
target_include_directories(${PROJECT_NAME} PRIVATE ${VapourSynthSDK}/include csv-parser/include) | ||
target_link_directories(${PROJECT_NAME} PRIVATE ${VapourSynthSDK}/lib64) | ||
target_link_libraries(${PROJECT_NAME} VapourSynth.lib csv) | ||
|
||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include "VapourSynth4.h" | ||
#include "VSHelper4.h" | ||
#include <memory> | ||
#include <vector> | ||
#include "csv.hpp" | ||
|
||
struct SCDetectData { | ||
private: | ||
const VSAPI* vsapi; | ||
public: | ||
VSNode* node; | ||
std::vector<int> scdata; | ||
|
||
explicit SCDetectData(const VSAPI* vsapi) noexcept : vsapi(vsapi) { | ||
|
||
} | ||
|
||
~SCDetectData() { | ||
vsapi->freeNode(node); | ||
} | ||
}; | ||
|
||
|
||
static const VSFrame* VS_CC filterGetFrame(int n, int activationReason, void* instanceData, void** frameData, VSFrameContext* frameCtx, VSCore* core, const VSAPI* vsapi) { | ||
SCDetectData* d = (SCDetectData*)instanceData; | ||
|
||
if (activationReason == arInitial) { | ||
vsapi->requestFrameFilter(n, d->node, frameCtx); | ||
} | ||
else if (activationReason == arAllFramesReady) { | ||
const VSFrame* frame = vsapi->getFrameFilter(n, d->node, frameCtx); | ||
|
||
/* your code here... */ | ||
|
||
return frame; | ||
} | ||
|
||
return nullptr; | ||
} | ||
|
||
static void VS_CC filterFree(void* instanceData, VSCore* core, const VSAPI* vsapi) { | ||
delete reinterpret_cast<SCDetectData*>(instanceData); | ||
} | ||
|
||
static void VS_CC filterCreate(const VSMap* in, VSMap* out, void* userData, VSCore* core, const VSAPI* vsapi) { | ||
auto data{ std::make_unique<SCDetectData>(vsapi) }; | ||
|
||
data->node = vsapi->mapGetNode(in, "clip", 0, nullptr); | ||
|
||
csv::CSVReader reader(vsapi->mapGetData(in, "scfile", 0, nullptr)); | ||
for (csv::CSVRow& row : reader) { | ||
data->scdata.push_back(row["Start Frame"].get<int>()); | ||
} | ||
|
||
VSFilterDependency deps[] = { {data->node, rpGeneral} }; /* Depending the the request patterns you may want to change this */ | ||
vsapi->createVideoFilter(out, "SCDetect", vsapi->getVideoInfo(data->node), filterGetFrame, filterFree, fmParallel, deps, 1, data.release(), core); | ||
} | ||
|
||
////////////////////////////////////////// | ||
// Init | ||
|
||
VS_EXTERNAL_API(void) VapourSynthPluginInit2(VSPlugin* plugin, const VSPLUGINAPI* vspapi) { | ||
vspapi->configPlugin("com.tomcup.SCDetect", "misc", "Mark the clip with PySceneDetect's output", VS_MAKE_VERSION(0, 1), VAPOURSYNTH_API_VERSION, 0, plugin); | ||
vspapi->registerFunction("SCDetect", "clip:vnode;scfile:data[]", "clip:vnode;", filterCreate, nullptr, plugin); | ||
} |