vapoursynth-vszip 13.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vapoursynth_vszip-13.0.0/.gitignore +11 -0
- vapoursynth_vszip-13.0.0/LICENSE +21 -0
- vapoursynth_vszip-13.0.0/PKG-INFO +68 -0
- vapoursynth_vszip-13.0.0/README.md +58 -0
- vapoursynth_vszip-13.0.0/build.zig +67 -0
- vapoursynth_vszip-13.0.0/build.zig.zon +20 -0
- vapoursynth_vszip-13.0.0/hatch_build.py +144 -0
- vapoursynth_vszip-13.0.0/pyproject.toml +36 -0
- vapoursynth_vszip-13.0.0/src/filters/bilateral.zig +648 -0
- vapoursynth_vszip-13.0.0/src/filters/boxblur_comptime.zig +158 -0
- vapoursynth_vszip-13.0.0/src/filters/boxblur_runtime.zig +162 -0
- vapoursynth_vszip-13.0.0/src/filters/checkmate.zig +57 -0
- vapoursynth_vszip-13.0.0/src/filters/clahe.zig +155 -0
- vapoursynth_vszip-13.0.0/src/filters/color_map.zig +183 -0
- vapoursynth_vszip-13.0.0/src/filters/comb_mask.zig +189 -0
- vapoursynth_vszip-13.0.0/src/filters/comb_mask_mt.zig +60 -0
- vapoursynth_vszip-13.0.0/src/filters/deband_float.zig +315 -0
- vapoursynth_vszip-13.0.0/src/filters/deband_int.zig +337 -0
- vapoursynth_vszip-13.0.0/src/filters/limit_filter.zig +34 -0
- vapoursynth_vszip-13.0.0/src/filters/limiter.zig +91 -0
- vapoursynth_vszip-13.0.0/src/filters/planeaverage.zig +84 -0
- vapoursynth_vszip-13.0.0/src/filters/planeminmax.zig +248 -0
- vapoursynth_vszip-13.0.0/src/filters/ssimulacra2.zig +671 -0
- vapoursynth_vszip-13.0.0/src/filters/xpsnr.zig +380 -0
- vapoursynth_vszip-13.0.0/src/helper.zig +460 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/adaptive_binarize.zig +107 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/bilateral.zig +247 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/boxblur.zig +162 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/checkmate.zig +142 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/clahe.zig +101 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/color_map.zig +105 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/comb_mask.zig +142 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/comb_mask_mt.zig +118 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/deband.zig +512 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/image_read.zig +304 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/limit_filter.zig +130 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/limiter.zig +217 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/packrgb.zig +110 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/planeaverage.zig +154 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/planeminmax.zig +198 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/rfs.zig +173 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/ssimulacra2.zig +128 -0
- vapoursynth_vszip-13.0.0/src/vapoursynth/xpsnr.zig +200 -0
- vapoursynth_vszip-13.0.0/src/vcl.zig +256 -0
- vapoursynth_vszip-13.0.0/src/vszip.zig +179 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Julek
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vapoursynth-vszip
|
|
3
|
+
Version: 13.0.0
|
|
4
|
+
Summary: VapourSynth Zig Image Process
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.12
|
|
8
|
+
Requires-Dist: vapoursynth>=74
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
## VapourSynth Zig Image Process
|
|
12
|
+
|
|
13
|
+
[READ THE DOCS](https://github.com/dnjulek/vapoursynth-zip/wiki)
|
|
14
|
+
|
|
15
|
+
# FILTERS
|
|
16
|
+
- [AdaptiveBinarize](https://github.com/dnjulek/vapoursynth-zip/wiki/AdaptiveBinarize): based on [OpenCV's Adaptive Thresholding](https://docs.opencv.org/5.x/d7/d4d/tutorial_py_thresholding.html).
|
|
17
|
+
- [Bilateral](https://github.com/dnjulek/vapoursynth-zip/wiki/Bilateral): A faster version of [VapourSynth-Bilateral](https://github.com/HomeOfVapourSynthEvolution/VapourSynth-Bilateral).
|
|
18
|
+
- [BoxBlur](https://github.com/dnjulek/vapoursynth-zip/wiki/BoxBlur): A faster version of [std.BoxBlur](https://www.vapoursynth.com/doc/functions/video/boxblur.html).
|
|
19
|
+
- [Checkmate](https://github.com/dnjulek/vapoursynth-zip/wiki/Checkmate): Spatial and temporal dot crawl reducer [from AviSynth](https://github.com/tp7/checkmate).
|
|
20
|
+
- [CLAHE](https://github.com/dnjulek/vapoursynth-zip/wiki/CLAHE): Contrast Limited Adaptive Histogram Equalization [from OpenCV](https://docs.opencv.org/5.x/d5/daf/tutorial_py_histogram_equalization.html).
|
|
21
|
+
- [ColorMap](https://github.com/dnjulek/vapoursynth-zip/wiki/ColorMap): A port of the [OpenCV ColorMap](https://docs.opencv.org/5.x/d3/d50/group__imgproc__colormap.html).
|
|
22
|
+
- [CombMask](https://github.com/dnjulek/vapoursynth-zip/wiki/CombMask): Port of CombMask [from AviSynth](http://avisynth.nl/index.php/CombMask).
|
|
23
|
+
- [CombMaskMT](https://github.com/dnjulek/vapoursynth-zip/wiki/CombMaskMT): Port of MTCombMask [from AviSynth](http://avisynth.nl/index.php/MTCombMask).
|
|
24
|
+
- [Deband](https://github.com/dnjulek/vapoursynth-zip/wiki/Deband): A faster version of [neo_f3kdb](https://github.com/HomeOfAviSynthPlusEvolution/neo_f3kdb) with float support.
|
|
25
|
+
- [ImageRead](https://github.com/dnjulek/vapoursynth-zip/wiki/ImageRead): Load image using [Zig Image library](https://github.com/zigimg/zigimg).
|
|
26
|
+
- [Limiter](https://github.com/dnjulek/vapoursynth-zip/wiki/Limiter): A faster version of [core.std.Limiter](https://www.vapoursynth.com/doc/functions/video/limiter.html).
|
|
27
|
+
- [LimitFilter](https://github.com/dnjulek/vapoursynth-zip/wiki/LimitFilter): Performs a soft-limiting between two clips to limit the difference of filtering while avoiding artifacts.
|
|
28
|
+
- [PackRGB](https://github.com/dnjulek/vapoursynth-zip/wiki/PackRGB): Planar to interleaved RGB filter.
|
|
29
|
+
- [PlaneAverage](https://github.com/dnjulek/vapoursynth-zip/wiki/PlaneAverage): Vapoursynth [PlaneStats](https://www.vapoursynth.com/doc/functions/video/planestats.html) with threshold.
|
|
30
|
+
- [PlaneMinMax](https://github.com/dnjulek/vapoursynth-zip/wiki/PlaneMinMax): Vapoursynth [PlaneStats](https://www.vapoursynth.com/doc/functions/video/planestats.html) with threshold.
|
|
31
|
+
- [RFS](https://github.com/dnjulek/vapoursynth-zip/wiki/RFS): Replace frames plugin.
|
|
32
|
+
- [SSIMULACRA2](https://github.com/dnjulek/vapoursynth-zip/wiki/SSIMULACRA2): Image metric [SSIMULACRA2](https://github.com/cloudinary/ssimulacra2).
|
|
33
|
+
- [XPSNR](https://github.com/dnjulek/vapoursynth-zip/wiki/XPSNR): Image metric [XPSNR](https://github.com/fraunhoferhhi/xpsnr).
|
|
34
|
+
|
|
35
|
+
# BENCHMARK
|
|
36
|
+
|
|
37
|
+
```py
|
|
38
|
+
src = core.std.BlankClip(None, 1920, 1080, vs.YUV420P16, 5000)
|
|
39
|
+
|
|
40
|
+
src.bilateral.Bilateral(ref=None, sigmaS=2, sigmaR=2, planes=[0,1,2]).set_output(1)
|
|
41
|
+
# Output 5000 frames in 43.35 seconds (115.35 fps)
|
|
42
|
+
src.vszip.Bilateral(ref=None, sigmaS=2, sigmaR=2, planes=[0,1,2]).set_output(2)
|
|
43
|
+
# Output 5000 frames in 35.37 seconds (141.36 fps)
|
|
44
|
+
|
|
45
|
+
src.std.BoxBlur(hradius=13, hpasses=1, vradius=13, vpasses=1).set_output(3)
|
|
46
|
+
# Output 5000 frames in 16.74 seconds (298.60 fps)
|
|
47
|
+
src.vszip.BoxBlur(hradius=13, hpasses=1, vradius=13, vpasses=1).set_output(4)
|
|
48
|
+
# Output 5000 frames in 4.78 seconds (1046.11 fps)
|
|
49
|
+
|
|
50
|
+
src.std.BoxBlur(hradius=13, hpasses=5, vradius=13, vpasses=5).set_output(5)
|
|
51
|
+
# Output 5000 frames in 76.72 seconds (65.17 fps)
|
|
52
|
+
src.vszip.BoxBlur(hradius=13, hpasses=5, vradius=13, vpasses=5).set_output(6)
|
|
53
|
+
# Output 5000 frames in 13.62 seconds (367.01 fps)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Building
|
|
57
|
+
|
|
58
|
+
- Via manual download:\
|
|
59
|
+
Put [zig-0.15.2](https://ziglang.org/download/) in your PATH and run: ``zig build -Doptimize=ReleaseFast``.
|
|
60
|
+
- Via automated scripts:
|
|
61
|
+
```ps
|
|
62
|
+
git clone https://github.com/dnjulek/vapoursynth-zip
|
|
63
|
+
cd vapoursynth-zip/build-help && ./build.ps1
|
|
64
|
+
```
|
|
65
|
+
- Via AUR (for Arch Linux):\
|
|
66
|
+
Run ``paru -S vapoursynth-plugin-vszip-git``
|
|
67
|
+
- Via vsrepo (for Windows):\
|
|
68
|
+
Run ``vsrepo install vszip``
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
## VapourSynth Zig Image Process
|
|
2
|
+
|
|
3
|
+
[READ THE DOCS](https://github.com/dnjulek/vapoursynth-zip/wiki)
|
|
4
|
+
|
|
5
|
+
# FILTERS
|
|
6
|
+
- [AdaptiveBinarize](https://github.com/dnjulek/vapoursynth-zip/wiki/AdaptiveBinarize): based on [OpenCV's Adaptive Thresholding](https://docs.opencv.org/5.x/d7/d4d/tutorial_py_thresholding.html).
|
|
7
|
+
- [Bilateral](https://github.com/dnjulek/vapoursynth-zip/wiki/Bilateral): A faster version of [VapourSynth-Bilateral](https://github.com/HomeOfVapourSynthEvolution/VapourSynth-Bilateral).
|
|
8
|
+
- [BoxBlur](https://github.com/dnjulek/vapoursynth-zip/wiki/BoxBlur): A faster version of [std.BoxBlur](https://www.vapoursynth.com/doc/functions/video/boxblur.html).
|
|
9
|
+
- [Checkmate](https://github.com/dnjulek/vapoursynth-zip/wiki/Checkmate): Spatial and temporal dot crawl reducer [from AviSynth](https://github.com/tp7/checkmate).
|
|
10
|
+
- [CLAHE](https://github.com/dnjulek/vapoursynth-zip/wiki/CLAHE): Contrast Limited Adaptive Histogram Equalization [from OpenCV](https://docs.opencv.org/5.x/d5/daf/tutorial_py_histogram_equalization.html).
|
|
11
|
+
- [ColorMap](https://github.com/dnjulek/vapoursynth-zip/wiki/ColorMap): A port of the [OpenCV ColorMap](https://docs.opencv.org/5.x/d3/d50/group__imgproc__colormap.html).
|
|
12
|
+
- [CombMask](https://github.com/dnjulek/vapoursynth-zip/wiki/CombMask): Port of CombMask [from AviSynth](http://avisynth.nl/index.php/CombMask).
|
|
13
|
+
- [CombMaskMT](https://github.com/dnjulek/vapoursynth-zip/wiki/CombMaskMT): Port of MTCombMask [from AviSynth](http://avisynth.nl/index.php/MTCombMask).
|
|
14
|
+
- [Deband](https://github.com/dnjulek/vapoursynth-zip/wiki/Deband): A faster version of [neo_f3kdb](https://github.com/HomeOfAviSynthPlusEvolution/neo_f3kdb) with float support.
|
|
15
|
+
- [ImageRead](https://github.com/dnjulek/vapoursynth-zip/wiki/ImageRead): Load image using [Zig Image library](https://github.com/zigimg/zigimg).
|
|
16
|
+
- [Limiter](https://github.com/dnjulek/vapoursynth-zip/wiki/Limiter): A faster version of [core.std.Limiter](https://www.vapoursynth.com/doc/functions/video/limiter.html).
|
|
17
|
+
- [LimitFilter](https://github.com/dnjulek/vapoursynth-zip/wiki/LimitFilter): Performs a soft-limiting between two clips to limit the difference of filtering while avoiding artifacts.
|
|
18
|
+
- [PackRGB](https://github.com/dnjulek/vapoursynth-zip/wiki/PackRGB): Planar to interleaved RGB filter.
|
|
19
|
+
- [PlaneAverage](https://github.com/dnjulek/vapoursynth-zip/wiki/PlaneAverage): Vapoursynth [PlaneStats](https://www.vapoursynth.com/doc/functions/video/planestats.html) with threshold.
|
|
20
|
+
- [PlaneMinMax](https://github.com/dnjulek/vapoursynth-zip/wiki/PlaneMinMax): Vapoursynth [PlaneStats](https://www.vapoursynth.com/doc/functions/video/planestats.html) with threshold.
|
|
21
|
+
- [RFS](https://github.com/dnjulek/vapoursynth-zip/wiki/RFS): Replace frames plugin.
|
|
22
|
+
- [SSIMULACRA2](https://github.com/dnjulek/vapoursynth-zip/wiki/SSIMULACRA2): Image metric [SSIMULACRA2](https://github.com/cloudinary/ssimulacra2).
|
|
23
|
+
- [XPSNR](https://github.com/dnjulek/vapoursynth-zip/wiki/XPSNR): Image metric [XPSNR](https://github.com/fraunhoferhhi/xpsnr).
|
|
24
|
+
|
|
25
|
+
# BENCHMARK
|
|
26
|
+
|
|
27
|
+
```py
|
|
28
|
+
src = core.std.BlankClip(None, 1920, 1080, vs.YUV420P16, 5000)
|
|
29
|
+
|
|
30
|
+
src.bilateral.Bilateral(ref=None, sigmaS=2, sigmaR=2, planes=[0,1,2]).set_output(1)
|
|
31
|
+
# Output 5000 frames in 43.35 seconds (115.35 fps)
|
|
32
|
+
src.vszip.Bilateral(ref=None, sigmaS=2, sigmaR=2, planes=[0,1,2]).set_output(2)
|
|
33
|
+
# Output 5000 frames in 35.37 seconds (141.36 fps)
|
|
34
|
+
|
|
35
|
+
src.std.BoxBlur(hradius=13, hpasses=1, vradius=13, vpasses=1).set_output(3)
|
|
36
|
+
# Output 5000 frames in 16.74 seconds (298.60 fps)
|
|
37
|
+
src.vszip.BoxBlur(hradius=13, hpasses=1, vradius=13, vpasses=1).set_output(4)
|
|
38
|
+
# Output 5000 frames in 4.78 seconds (1046.11 fps)
|
|
39
|
+
|
|
40
|
+
src.std.BoxBlur(hradius=13, hpasses=5, vradius=13, vpasses=5).set_output(5)
|
|
41
|
+
# Output 5000 frames in 76.72 seconds (65.17 fps)
|
|
42
|
+
src.vszip.BoxBlur(hradius=13, hpasses=5, vradius=13, vpasses=5).set_output(6)
|
|
43
|
+
# Output 5000 frames in 13.62 seconds (367.01 fps)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Building
|
|
47
|
+
|
|
48
|
+
- Via manual download:\
|
|
49
|
+
Put [zig-0.15.2](https://ziglang.org/download/) in your PATH and run: ``zig build -Doptimize=ReleaseFast``.
|
|
50
|
+
- Via automated scripts:
|
|
51
|
+
```ps
|
|
52
|
+
git clone https://github.com/dnjulek/vapoursynth-zip
|
|
53
|
+
cd vapoursynth-zip/build-help && ./build.ps1
|
|
54
|
+
```
|
|
55
|
+
- Via AUR (for Arch Linux):\
|
|
56
|
+
Run ``paru -S vapoursynth-plugin-vszip-git``
|
|
57
|
+
- Via vsrepo (for Windows):\
|
|
58
|
+
Run ``vsrepo install vszip``
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const std = @import("std");
|
|
2
|
+
const zon = @import("build.zig.zon");
|
|
3
|
+
|
|
4
|
+
pub fn build(b: *std.Build) !void {
|
|
5
|
+
ensureZigVersion(try .parse(zon.minimum_zig_version)) catch return;
|
|
6
|
+
const target = b.standardTargetOptions(.{});
|
|
7
|
+
const optimize = b.standardOptimizeOption(.{});
|
|
8
|
+
|
|
9
|
+
const lib = b.addLibrary(.{
|
|
10
|
+
.name = "vszip",
|
|
11
|
+
.linkage = .dynamic,
|
|
12
|
+
.root_module = b.createModule(.{
|
|
13
|
+
.root_source_file = b.path("src/vszip.zig"),
|
|
14
|
+
.target = target,
|
|
15
|
+
.optimize = optimize,
|
|
16
|
+
}),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const options = b.addOptions();
|
|
20
|
+
const version = try std.SemanticVersion.parse(zon.version);
|
|
21
|
+
options.addOption(std.SemanticVersion, "version", version);
|
|
22
|
+
lib.root_module.addOptions("zon", options);
|
|
23
|
+
|
|
24
|
+
const zigimg_dependency = b.dependency("zigimg", .{
|
|
25
|
+
.target = target,
|
|
26
|
+
.optimize = optimize,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
lib.root_module.addImport("zigimg", zigimg_dependency.module("zigimg"));
|
|
30
|
+
|
|
31
|
+
const vapoursynth_dep = b.dependency("vapoursynth", .{
|
|
32
|
+
.target = target,
|
|
33
|
+
.optimize = optimize,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
lib.root_module.addImport("vapoursynth", vapoursynth_dep.module("vapoursynth"));
|
|
37
|
+
lib.linkLibC();
|
|
38
|
+
|
|
39
|
+
if (lib.root_module.optimize == .ReleaseFast) {
|
|
40
|
+
lib.root_module.strip = true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
b.installArtifact(lib);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
fn ensureZigVersion(min_zig_version: std.SemanticVersion) !void {
|
|
47
|
+
var installed_ver = @import("builtin").zig_version;
|
|
48
|
+
installed_ver.build = null;
|
|
49
|
+
|
|
50
|
+
if (installed_ver.order(min_zig_version) == .lt) {
|
|
51
|
+
std.log.err("\n" ++
|
|
52
|
+
\\---------------------------------------------------------------------------
|
|
53
|
+
\\
|
|
54
|
+
\\Installed Zig compiler version is too old.
|
|
55
|
+
\\
|
|
56
|
+
\\Min. required version: {any}
|
|
57
|
+
\\Installed version: {any}
|
|
58
|
+
\\
|
|
59
|
+
\\Please install newer version and try again.
|
|
60
|
+
\\Latest version can be found here: https://ziglang.org/download/
|
|
61
|
+
\\
|
|
62
|
+
\\---------------------------------------------------------------------------
|
|
63
|
+
\\
|
|
64
|
+
, .{ min_zig_version, installed_ver });
|
|
65
|
+
return error.ZigIsTooOld;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.{
|
|
2
|
+
.name = .vszip,
|
|
3
|
+
.version = "13.0.0",
|
|
4
|
+
.paths = .{""},
|
|
5
|
+
.fingerprint = 0x7466a154dbe09310,
|
|
6
|
+
.minimum_zig_version = "0.15.2",
|
|
7
|
+
.dependencies = .{
|
|
8
|
+
.vapoursynth = .{
|
|
9
|
+
// zig fetch --save git+https://github.com/dnjulek/vapoursynth-zig.git
|
|
10
|
+
.url = "git+https://github.com/dnjulek/vapoursynth-zig.git#8e93fe3433bb977135f81040bb59d964c58a1cb9",
|
|
11
|
+
.hash = "vapoursynth-4.0.0-jLYMQ799AgCA8sL5lgewK9acIrAKjs-ByT2pdKI5dHq2",
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
.zigimg = .{
|
|
15
|
+
// zig fetch --save git+https://github.com/zigimg/zigimg.git
|
|
16
|
+
.url = "git+https://github.com/zigimg/zigimg.git#362cdd6bce109f7bc674be134cddd378f52da5d4",
|
|
17
|
+
.hash = "zigimg-0.1.0-8_eo2jNrFQD4mu3EAUkfQRmCkyfprdIXc8JQ6uyxhjSQ",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import shutil
|
|
4
|
+
import subprocess
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
|
9
|
+
from packaging import tags
|
|
10
|
+
|
|
11
|
+
library_suffixes = frozenset({'.so', '.dll', '.dylib'})
|
|
12
|
+
|
|
13
|
+
cpus = [
|
|
14
|
+
{'cpu': 'x86_64'},
|
|
15
|
+
{'cpu': 'haswell', 'opt_level': 'v3'},
|
|
16
|
+
{'cpu': 'znver4-sse4a', 'opt_level': 'v4'}, # "-sse4a" means *remove* the use of SSE4a (which Intel never implemented)
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
targets = {
|
|
20
|
+
# Linux
|
|
21
|
+
'aarch64-linux-gnu': {
|
|
22
|
+
'zig_target': 'aarch64-linux-gnu.2.17',
|
|
23
|
+
'python_platform_tag': 'manylinux_2_17_aarch64',
|
|
24
|
+
'basename': 'libvszip',
|
|
25
|
+
},
|
|
26
|
+
'aarch64-linux-musl': {
|
|
27
|
+
'zig_target': 'aarch64-linux-musl',
|
|
28
|
+
'python_platform_tag': 'musllinux_1_2_aarch64',
|
|
29
|
+
'basename': 'libvszip',
|
|
30
|
+
},
|
|
31
|
+
'x86_64-linux-gnu': {
|
|
32
|
+
'zig_target': 'x86_64-linux-gnu.2.17',
|
|
33
|
+
'python_platform_tag': 'manylinux_2_17_x86_64',
|
|
34
|
+
'basename': 'libvszip',
|
|
35
|
+
'cpus': cpus,
|
|
36
|
+
},
|
|
37
|
+
'x86_64-linux-musl': {
|
|
38
|
+
'zig_target': 'x86_64-linux-musl',
|
|
39
|
+
'python_platform_tag': 'musllinux_1_2_x86_64',
|
|
40
|
+
'basename': 'libvszip',
|
|
41
|
+
'cpus': cpus,
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
# Mac
|
|
45
|
+
'aarch64-macos': {
|
|
46
|
+
'zig_target': 'aarch64-macos',
|
|
47
|
+
'python_platform_tag': 'macosx_11_0_arm64',
|
|
48
|
+
'basename': 'libvszip',
|
|
49
|
+
},
|
|
50
|
+
'x86_64-macos': {
|
|
51
|
+
'zig_target': 'x86_64-macos',
|
|
52
|
+
'python_platform_tag': 'macosx_11_0_x86_64',
|
|
53
|
+
'basename': 'libvszip',
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
# Windows
|
|
57
|
+
'x86_64-windows': {
|
|
58
|
+
'zig_target': 'x86_64-windows',
|
|
59
|
+
'python_platform_tag': 'win_amd64',
|
|
60
|
+
'basename': 'vszip',
|
|
61
|
+
'cpus': cpus,
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class CustomHook(BuildHookInterface[Any]):
|
|
67
|
+
"""
|
|
68
|
+
Custom build hook to compile the Zig project and package the resulting binaries.
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
source_dir = Path("zig-out")
|
|
72
|
+
target_dir = Path("vapoursynth/plugins/vszip")
|
|
73
|
+
|
|
74
|
+
def initialize(self, version: str, build_data: dict[str, Any]) -> None:
|
|
75
|
+
"""
|
|
76
|
+
Called before the build process starts.
|
|
77
|
+
Sets build metadata and executes the Zig compilation.
|
|
78
|
+
"""
|
|
79
|
+
# https://hatch.pypa.io/latest/plugins/builder/wheel/#build-data
|
|
80
|
+
build_data["pure_python"] = False
|
|
81
|
+
|
|
82
|
+
# Ensure the target directory exists
|
|
83
|
+
self.target_dir.mkdir(parents=True, exist_ok=True)
|
|
84
|
+
|
|
85
|
+
# Cross-compilation support
|
|
86
|
+
if "ZTARGET" in os.environ:
|
|
87
|
+
# Ex: ZTARGET="x86_64-linux-gnu"
|
|
88
|
+
ztarget = os.environ["ZTARGET"]
|
|
89
|
+
|
|
90
|
+
if ztarget not in targets:
|
|
91
|
+
raise ValueError(f"Unsupported target {ztarget}")
|
|
92
|
+
|
|
93
|
+
target = targets[ztarget]
|
|
94
|
+
zig_target = target['zig_target']
|
|
95
|
+
python_platform_tag = target['python_platform_tag']
|
|
96
|
+
|
|
97
|
+
build_data["tag"] = f"py3-none-{python_platform_tag}"
|
|
98
|
+
|
|
99
|
+
if 'cpus' in target:
|
|
100
|
+
# Build all optimization levels of the library
|
|
101
|
+
for cpu_spec in target['cpus']:
|
|
102
|
+
subprocess.run([sys.executable, "-m", "ziglang", "build", "-Doptimize=ReleaseFast", f"-Dtarget={zig_target}", f"-Dcpu={cpu_spec['cpu']}"], check=True)
|
|
103
|
+
|
|
104
|
+
for file_path in self.source_dir.rglob("*"):
|
|
105
|
+
if file_path.is_file() and file_path.suffix in library_suffixes:
|
|
106
|
+
if 'opt_level' in cpu_spec:
|
|
107
|
+
name = file_path.stem + f".{cpu_spec['opt_level']}" + file_path.suffix
|
|
108
|
+
shutil.copy2(file_path, Path(self.target_dir, name))
|
|
109
|
+
else:
|
|
110
|
+
shutil.copy2(file_path, self.target_dir)
|
|
111
|
+
else:
|
|
112
|
+
subprocess.run([sys.executable, "-m", "ziglang", "build", "-Doptimize=ReleaseFast", f"-Dtarget={zig_target}"], check=True)
|
|
113
|
+
|
|
114
|
+
for file_path in self.source_dir.rglob("*"):
|
|
115
|
+
if file_path.is_file() and file_path.suffix in library_suffixes:
|
|
116
|
+
shutil.copy2(file_path, self.target_dir)
|
|
117
|
+
|
|
118
|
+
# Write a manifest to ensure instruction set-based loading works as desired
|
|
119
|
+
# https://github.com/vapoursynth/vapoursynth/discussions/1196
|
|
120
|
+
manifest_path = Path(self.target_dir, "manifest.vs")
|
|
121
|
+
with open(manifest_path, "wt") as manifest:
|
|
122
|
+
manifest.writelines([
|
|
123
|
+
"[VapourSynth Manifest V1]\n"
|
|
124
|
+
f"{target['basename']}\n"
|
|
125
|
+
])
|
|
126
|
+
|
|
127
|
+
# Build for *this* machine
|
|
128
|
+
else:
|
|
129
|
+
build_data["tag"] = f"py3-none-{next(tags.platform_tags())}"
|
|
130
|
+
|
|
131
|
+
subprocess.run([sys.executable, "-m", "ziglang", "build", "-Doptimize=ReleaseFast"], check=True)
|
|
132
|
+
|
|
133
|
+
# Copy the compiled binaries
|
|
134
|
+
for file_path in self.source_dir.rglob("*"):
|
|
135
|
+
if file_path.is_file() and file_path.suffix in library_suffixes:
|
|
136
|
+
shutil.copy2(file_path, self.target_dir)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def finalize(self, version: str, build_data: dict[str, Any], artifact_path: str) -> None:
|
|
140
|
+
"""
|
|
141
|
+
Called after the build process finishes.
|
|
142
|
+
Cleans up temporary build artifacts.
|
|
143
|
+
"""
|
|
144
|
+
shutil.rmtree(self.target_dir.parent, ignore_errors=True)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.29.0", "packaging", "ziglang==0.15.2"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "vapoursynth-vszip"
|
|
7
|
+
description = "VapourSynth Zig Image Process"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
license = "MIT"
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
dependencies = ["VapourSynth>=74"]
|
|
12
|
+
dynamic = ["version"]
|
|
13
|
+
|
|
14
|
+
[tool.hatch.version]
|
|
15
|
+
source = "regex"
|
|
16
|
+
path = "build.zig.zon"
|
|
17
|
+
pattern = '\.version\s*=\s*"(?P<version>[^"]+)"'
|
|
18
|
+
|
|
19
|
+
[tool.hatch.build.targets.sdist]
|
|
20
|
+
include = [
|
|
21
|
+
"src",
|
|
22
|
+
"build.zig",
|
|
23
|
+
"build.zig.zon",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[tool.hatch.build.targets.wheel]
|
|
27
|
+
include = ["vapoursynth/plugins/vszip"]
|
|
28
|
+
artifacts = [
|
|
29
|
+
"vapoursynth/plugins/vszip/*.dylib",
|
|
30
|
+
"vapoursynth/plugins/vszip/*.so",
|
|
31
|
+
"vapoursynth/plugins/vszip/*.dll",
|
|
32
|
+
"vapoursynth/plugins/vszip/manifest.vs",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[tool.hatch.build.targets.wheel.hooks.custom]
|
|
36
|
+
path = "hatch_build.py"
|