Skip to content

Commit 6ebe1be

Browse files
committed
Added PLUGIN development!!!
- Added new API functions in `lib.rs` for better integration with external modules. - Implemented conversion from `Error` to `String` in `errors.rs` for improved error handling. - Simplified iterator implementations in `iterators.rs` by consolidating macro usage. - Updated `Map` struct methods in `mod.rs` for better safety and usability, including new `get_string` and `set_string` methods. - Improved test coverage in `tests.rs` for various map functionalities. - Refactored `node/mod.rs` to streamline frame handling and caching options. - Introduced `PluginConfigFlags` in `plugin.rs` for enhanced plugin configuration. - Cleaned up `vsscript/mod.rs` and `tests.rs` for consistency and clarity.
1 parent 0631738 commit 6ebe1be

26 files changed

Lines changed: 1038 additions & 286 deletions

File tree

.github/workflows/ci.yml

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,50 @@ jobs:
1010
env:
1111
LD_LIBRARY_PATH: /usr/local/lib
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v5
1414
with:
1515
submodules: recursive
16-
- name: Build vapoursynth
16+
- name: Cache cargo
17+
uses: actions/cache@v4
18+
with:
19+
path: |
20+
~/.cargo/bin/
21+
~/.cargo/registry/index/
22+
~/.cargo/registry/cache/
23+
~/.cargo/git/db/
24+
target/
25+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
26+
- name: Cache zimg
27+
uses: actions/cache@v4
28+
id: cache-zimg
29+
with:
30+
path: /usr/local/lib/libzimg*
31+
key: ${{ runner.os }}-zimg-3.0.6
32+
- name: Cache vapoursynth
33+
uses: actions/cache@v4
34+
id: cache-vapoursynth
35+
with:
36+
path: |
37+
/usr/local/lib/libvapoursynth*
38+
/usr/local/include/vapoursynth
39+
key: ${{ runner.os }}-vapoursynth-${{ hashFiles('rustsynth-sys/vapoursynth/**') }}
40+
- name: Install system dependencies
1741
run: |
1842
sudo apt-get update
19-
sudo apt-get install g++ make autoconf automake libtool pkg-config nasm git
43+
sudo apt-get --yes install g++ make autoconf automake libtool pkg-config nasm git libclang-dev python3 python3-dev
44+
pip install Cython
45+
- name: Build zimg
46+
if: steps.cache-zimg.outputs.cache-hit != 'true'
47+
run: |
2048
git clone --branch release-3.0.6 --depth 1 https://github.com/sekrit-twc/zimg.git
21-
cd zimg
49+
cd zimg
2250
./autogen.sh
2351
./configure
2452
make
2553
sudo make install
26-
cd ..
27-
sudo apt-get install cython3
54+
- name: Build vapoursynth
55+
if: steps.cache-vapoursynth.outputs.cache-hit != 'true'
56+
run: |
2857
cd rustsynth-sys/vapoursynth
2958
./autogen.sh
3059
./configure
@@ -46,9 +75,18 @@ jobs:
4675
name: macOS - build, test and lint
4776
runs-on: macos-latest
4877
steps:
49-
- uses: actions/checkout@v2
78+
- uses: actions/checkout@v5
5079
with:
5180
submodules: recursive
81+
- uses: actions/cache@v4
82+
with:
83+
path: |
84+
~/.cargo/bin/
85+
~/.cargo/registry/index/
86+
~/.cargo/registry/cache/
87+
~/.cargo/git/db/
88+
target/
89+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
5290
- name: Install VapourSynth
5391
run: |
5492
brew install vapoursynth

.github/workflows/docs.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,22 @@ jobs:
1818
name: Build and Release Docs
1919
runs-on: ubuntu-latest
2020
steps:
21-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v5
2222
with:
2323
submodules: recursive
24+
- uses: actions/cache@v4
25+
with:
26+
path: |
27+
~/.cargo/bin/
28+
~/.cargo/registry/index/
29+
~/.cargo/registry/cache/
30+
~/.cargo/git/db/
31+
target/
32+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
33+
- name: Ensure libclang
34+
run: |
35+
apt update
36+
apt install --yes libclang-dev
2437
- name: Run doc
2538
run: |
2639
cargo doc --workspace --no-deps

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[workspace]
22
resolver = "2"
3-
members = ["rustsynth", "rustsynth-sys", "rustsynth-derive"]
3+
members = ["rustsynth", "rustsynth-sys", "rustsynth-derive", "example"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Fork of [vapoursynth-rs](https://github.com/YaLTeR/vapoursynth-rs) for the lates
44

55
**[support and dev discord](https://discord.com/invite/5z3YhWstQr)**
66

7-
[Docs for main branch](https://rustsynth.animafps.xyz/rustsynth/index.html)
7+
[Docs for main branch](https://animafps.github.io/rustsynth/rustsynth/index.html)
88

99
## rustsynth
1010

example/src/lib.rs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
use rustsynth::{
2+
core::CoreRef,
3+
filter::{
4+
traits::{Filter},
5+
FilterDependency, FilterMode, RequestPattern,
6+
},
7+
frame::{Frame, FrameContext},
8+
map::Map,
9+
node::Node,
10+
};
11+
use rustsynth_derive::vapoursynth_plugin;
12+
13+
#[vapoursynth_plugin]
14+
mod plugin {
15+
use rustsynth::{ffi, plugin::PluginConfigFlags, MakeVersion};
16+
use rustsynth_derive::vapoursynth_filter;
17+
const NAMESPACE: &'static str = "example";
18+
const ID: &'static str = "com.example.invert";
19+
const NAME: &'static str = "Example Plugin";
20+
const PLUGIN_VER: i32 = MakeVersion!(1,0);
21+
const API_VER: i32 = ffi::VAPOURSYNTH_API_VERSION;
22+
const FLAGS: i32 = PluginConfigFlags::NONE.bits();
23+
24+
#[vapoursynth_filter(video)]
25+
struct Invert {
26+
input_node: Node,
27+
}
28+
29+
// Just implement the trait methods and the macro handles all C FFI
30+
impl Filter for Invert {
31+
const NAME: &'static str = "Invert";
32+
const ARGS: &'static str = "clip:vnode;";
33+
const RETURNTYPE: &'static str = "clip:vnode;";
34+
const MODE: FilterMode = FilterMode::Parallel;
35+
36+
fn from_args(args: &Map, _core: &CoreRef) -> Result<Self, String> {
37+
let input_node = args.get_node("clip")?;
38+
Ok(Self { input_node })
39+
}
40+
41+
fn get_dependencies(&self) -> Vec<FilterDependency> {
42+
vec![FilterDependency {
43+
source: self.input_node.clone(),
44+
request_pattern: RequestPattern::StrictSpatial,
45+
}]
46+
}
47+
48+
fn request_input_frames(&self, n: i32, frame_ctx: FrameContext) {
49+
self.get_dependencies()[0]
50+
.source
51+
.request_frame_filter(n, &frame_ctx);
52+
}
53+
54+
fn process_frame<'core>(
55+
&mut self,
56+
n: i32,
57+
_frame_data: &[u8; 4],
58+
frame_ctx: FrameContext,
59+
core: CoreRef<'core>,
60+
) -> Result<Frame<'core>, String> {
61+
let src = self.input_node.get_frame_filter(n, &frame_ctx).unwrap();
62+
// simple pass through
63+
Ok(src)
64+
}
65+
}
66+
67+
// Register all filters in this plugin
68+
rustsynth::register_filters!(Invert);
69+
}

0 commit comments

Comments
 (0)