Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ documentation (library usage, speed testing, MOS correlation, etc).

## Usage

Compilation requires [Zig](https://ziglang.org/) ≥0.16.0 & a macOS, Linux, or
Compilation requires [Zig](https://ziglang.org/) ≥0.17.0 & a macOS, Linux, or
Unix-like operating system. To compile, run:

```sh
zig build --release=fast
```

You may add `-Dflto=true` for FLTO, and `-Dstrip=true` to strip the binary.
You may add `-Dflto=true` for FLTO on ELF targets, and `-Dstrip=true` to strip
the binary. Zig 0.17 does not support this LTO build on macOS.

See [the benchmark notes](tests/bench/README.md) for performance and CID22
correlation results.

`fmetrics` binary usage:

Expand Down
25 changes: 10 additions & 15 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,13 @@ pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const strip = b.option(bool, "strip", "strip symbols from the binary, defaults to false") orelse false;
const flto = b.option(bool, "flto", "enable Link Time Optimization, defaults to false") orelse false;
if (flto and target.result.ofmt != .elf) {
const unsupported = b.addFail("Zig 0.17 LTO requires an ELF target; omit -Dflto=true on macOS");
b.default_step.dependOn(&unsupported.step);
return;
}
const options = b.addOptions();
const zon = b.build_root.handle.readFileAlloc(
b.graph.io,
"build.zig.zon",
b.allocator,
.limited(1 << 20),
) catch @panic("failed to read build.zig.zon");
const marker = ".version = \"";
const start = std.mem.indexOf(u8, zon, marker) orelse
@panic("missing version");
const value = zon[start + marker.len ..];
const end = std.mem.indexOfScalar(u8, value, '"') orelse
@panic("invalid version");
options.addOption([]const u8, "version", value[0..end]);
options.addOption([]const u8, "version", @import("build.zig.zon").version);

// simpleimgio
const simpleimgio_dep = b.dependency("simpleimgio", .{
Expand Down Expand Up @@ -83,6 +76,7 @@ pub fn build(b: *std.Build) void {
translate_c.addIncludePath(b.path("."));
translate_c.addIncludePath(spng.getEmittedIncludeTree());
const c_module = translate_c.createModule();
fmetrics_module.addImport("c", c_module);

// 'libfmetrics.a' static lib
const lib = b.addLibrary(.{
Expand All @@ -99,6 +93,7 @@ pub fn build(b: *std.Build) void {
lib.root_module.pic = true;
const lib_sources = [_][]const u8{
"src/fmetrics.c",
"src/ssimulacra2/ssimulacra2.c",
"src/fmetrics_cvvdp.c",
"src/iwssim/iwssim.c",
"src/msssim/msssim.c",
Expand Down Expand Up @@ -128,10 +123,10 @@ pub fn build(b: *std.Build) void {
if (target.result.cpu.arch == .x86_64) {
var avx_query = target.query;
avx_query.cpu_features_add.addFeature(
@intFromEnum(std.Target.x86.Feature.avx2),
@backingInt(std.Target.x86.Feature.avx2),
);
avx_query.cpu_features_add.addFeature(
@intFromEnum(std.Target.x86.Feature.fma),
@backingInt(std.Target.x86.Feature.fma),
);
const avx = b.addObject(.{
.name = "cvvdp_avx2",
Expand Down
14 changes: 7 additions & 7 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
.version = "0.1.0",
.dependencies = .{
.spng = .{
.url = "git+https://github.com/allyourcodebase/libspng.git#8858232bde47083739c3e25f676093423610ec5e",
.hash = "spng-0.0.1-T166cP8UAABcBGTOPKx7kUUyHEcu0eDvN8LnSIj3S_cW",
.url = "git+https://github.com/gianni-rosato/libspng.git?ref=main#bbd630d686262a56086bf8e9eddb8c4004f51c0c",
.hash = "spng-0.0.2-T166cHISAADR33WgZ6IfHBVOPj0gwjyqnxYxc-XTWF8Z",
},
.lcms2 = .{
.url = "git+https://github.com/allyourcodebase/lcms2.git#66c7c0ef0a9bd29a5f78aeff797bf541d0b91624",
.hash = "lcms2-2.18.0-CNsMs50PAAAbhEQvq2uI5_O2vqgvYXvcDKwFw8QbzKSk",
},
.simpleimgio = .{
.url = "git+https://github.com/gianni-rosato/simpleimgio.git#6d9b55ead31a181f82595ffaed05986476510126",
.hash = "simpleimgio-0.0.0-oHTuOdP9AADo0x_m-pBpu0Fi6GnqgVvbN_l2Ul4HbViE",
.url = "git+https://github.com/gianni-rosato/simpleimgio.git#98473d19f243eefd4ef29a2149af47bc072c2484",
.hash = "simpleimgio-0.0.1-oHTuOfMbAQBWcIe2wQBOoIIrItr8a-kBVowFbAaZkwXy",
},
.fcvvdp = .{
.url = "git+https://github.com/halidecx/fcvvdp.git#98bd21a7a876be29ba06a29325b03624047ee850",
.hash = "fcvvdp-0.4.0-DualWPL1BAD7bF7Jair50v5Se-G-VluA9Y2FElmJZe2y",
.url = "git+https://github.com/halidecx/fcvvdp.git#ab4d41df02138f5573c08e05e8e33c8ef397e613",
.hash = "fcvvdp-0.4.1-DualWIn4BAD_tcJHKx8OI1FWnSFpfeIm6dljEQHaYIFU",
},
},
.fingerprint = 0xcc4003cccc882e16,
.minimum_zig_version = "0.16.0",
.minimum_zig_version = "0.17.0",
.paths = .{
"build.zig",
"build.zig.zon",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=77", "wheel>=0.45", "ziglang==0.16.0"]
requires = ["setuptools>=77", "wheel>=0.45", "ziglang==0.17.0"]
build-backend = "setuptools.build_meta"

[project]
Expand Down
4 changes: 1 addition & 3 deletions src/fmetrics.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
// limitations under the License.
const std = @import("std");
const build_opts = @import("build_opts");
const c = @cImport({
@cInclude("fmetrics.h");
});
const c = @import("c");

pub const version = build_opts.version;

Expand Down
145 changes: 0 additions & 145 deletions src/ssimulacra2/err_map.zig

This file was deleted.

52 changes: 0 additions & 52 deletions src/ssimulacra2/linearlight.zig

This file was deleted.

Loading
Loading