Skip to content

Commit

Permalink
Fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
dnjulek committed Nov 21, 2023
1 parent 2cf1a94 commit 5d6e8e7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
6 changes: 3 additions & 3 deletions src/blur.zig
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ pub inline fn process(src: [*]const f32, dst: [*]f32, stride: usize, width: usiz
var i: usize = 0;
while (i < height) : (i += 1) {
var srcp: [9][*]const f32 = undefined;
var dstp: [*]f32 = dst + i * stride;
const dstp: [*]f32 = dst + i * stride;
const dist_from_bottom: usize = height - 1 - i;

var tmp_arr = allocator.alignedAlloc(f32, 32, width) catch unreachable;
const tmp_arr = allocator.alignedAlloc(f32, 32, width) catch unreachable;
defer allocator.free(tmp_arr);
var tmp: [*]f32 = tmp_arr.ptr;
const tmp: [*]f32 = tmp_arr.ptr;

var k: usize = 0;
while (k < radius) : (k += 1) {
Expand Down
2 changes: 1 addition & 1 deletion src/downscale.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub inline fn process(src: [3][*]f32, dst: [3][*]f32, src_stride: usize, in_w: u

var plane: usize = 0;
while (plane < 3) : (plane += 1) {
var srcp = src[plane];
const srcp = src[plane];
var dstp = dst[plane];
var oy: usize = 0;
while (oy < out_h) : (oy += 1) {
Expand Down
18 changes: 9 additions & 9 deletions src/score.zig
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ pub inline fn ssim_map(
var sum1 = [2]f64{ 0.0, 0.0 };
var y: usize = 0;
while (y < height) : (y += 1) {
var s11p = s11 + y * stride;
var s22p = s22 + y * stride;
var s12p = s12 + y * stride;
var mu1p = mu1 + y * stride;
var mu2p = mu2 + y * stride;
const s11p = s11 + y * stride;
const s22p = s22 + y * stride;
const s12p = s12 + y * stride;
const mu1p = mu1 + y * stride;
const mu2p = mu2 + y * stride;

var x: usize = 0;
while (x < width) : (x += 1) {
Expand Down Expand Up @@ -65,10 +65,10 @@ pub inline fn edge_map(
var sum2 = [4]f64{ 0.0, 0.0, 0.0, 0.0 };
var y: usize = 0;
while (y < height) : (y += 1) {
var im1p = im1 + y * stride;
var im2p = im2 + y * stride;
var mu1p = mu1 + y * stride;
var mu2p = mu2 + y * stride;
const im1p = im1 + y * stride;
const im2p = im2 + y * stride;
const mu1p = mu1 + y * stride;
const mu2p = mu2 + y * stride;

var x: usize = 0;
while (x < width) : (x += 1) {
Expand Down
36 changes: 18 additions & 18 deletions src/ssimulacra2.zig
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ inline fn process(src8a: [3][*]const u8, src8b: [3][*]const u8, tempp: [*]f32, s
};

const wh: usize = width * height;
var srcp1b = [3][*]f32{ tempp, tempp + wh, tempp + (wh * 2) };
var srcp2b = [3][*]f32{ tempp + (wh * 3), tempp + (wh * 4), tempp + (wh * 5) };
var tmpp1 = [3][*]f32{ tempp + (wh * 6), tempp + (wh * 7), tempp + (wh * 8) };
var tmpp2 = [3][*]f32{ tempp + (wh * 9), tempp + (wh * 10), tempp + (wh * 11) };
const srcp1b = [3][*]f32{ tempp, tempp + wh, tempp + (wh * 2) };
const srcp2b = [3][*]f32{ tempp + (wh * 3), tempp + (wh * 4), tempp + (wh * 5) };
const tmpp1 = [3][*]f32{ tempp + (wh * 6), tempp + (wh * 7), tempp + (wh * 8) };
const tmpp2 = [3][*]f32{ tempp + (wh * 9), tempp + (wh * 10), tempp + (wh * 11) };

var tmpp3: [*]f32 = tempp + (wh * 12);
var tmpps11: [*]f32 = tempp + (wh * 13);
var tmpps22: [*]f32 = tempp + (wh * 14);
var tmpps12: [*]f32 = tempp + (wh * 15);
var tmppmu1: [*]f32 = tempp + (wh * 16);
const tmpp3: [*]f32 = tempp + (wh * 12);
const tmpps11: [*]f32 = tempp + (wh * 13);
const tmpps22: [*]f32 = tempp + (wh * 14);
const tmpps12: [*]f32 = tempp + (wh * 15);
const tmppmu1: [*]f32 = tempp + (wh * 16);

var i: usize = 0;
const k: usize = width * height;
Expand Down Expand Up @@ -126,7 +126,7 @@ inline fn process(src8a: [3][*]const u8, src8b: [3][*]const u8, tempp: [*]f32, s

export fn ssimulacra2GetFrame(n: c_int, activation_reason: ar, instance_data: ?*anyopaque, frame_data: ?*?*anyopaque, frame_ctx: ?*vs.FrameContext, core: ?*vs.Core, vsapi: ?*const vs.API) callconv(.C) ?*const vs.Frame {
_ = frame_data;
var d: *Ssimulacra2Data = @ptrCast(@alignCast(instance_data));
const d: *Ssimulacra2Data = @ptrCast(@alignCast(instance_data));

if (activation_reason == ar.Initial) {
vsapi.?.requestFrameFilter.?(n, d.node1, frame_ctx);
Expand All @@ -140,23 +140,23 @@ export fn ssimulacra2GetFrame(n: c_int, activation_reason: ar, instance_data: ?*
const width: usize = @intCast(vsapi.?.getFrameWidth.?(src1, 0));
const height: usize = @intCast(vsapi.?.getFrameHeight.?(src1, 0));
const stride: usize = @intCast(vsapi.?.getStride.?(src1, 0));
var dst = vsapi.?.copyFrame.?(src2, core).?;
var tmp_arr = allocator.alignedAlloc(f32, 32, width * height * 18) catch unreachable;
const dst = vsapi.?.copyFrame.?(src2, core).?;
const tmp_arr = allocator.alignedAlloc(f32, 32, width * height * 18) catch unreachable;
defer allocator.free(tmp_arr);

var srcp1 = [3][*]const u8{
const srcp1 = [3][*]const u8{
vsapi.?.getReadPtr.?(src1, 0),
vsapi.?.getReadPtr.?(src1, 1),
vsapi.?.getReadPtr.?(src1, 2),
};

var srcp2 = [3][*]const u8{
const srcp2 = [3][*]const u8{
vsapi.?.getReadPtr.?(src2, 0),
vsapi.?.getReadPtr.?(src2, 1),
vsapi.?.getReadPtr.?(src2, 2),
};

var val = process(
const val = process(
srcp1,
srcp2,
tmp_arr.ptr,
Expand All @@ -173,7 +173,7 @@ export fn ssimulacra2GetFrame(n: c_int, activation_reason: ar, instance_data: ?*

export fn ssimulacra2Free(instance_data: ?*anyopaque, core: ?*vs.Core, vsapi: ?*const vs.API) callconv(.C) void {
_ = core;
var d: *Ssimulacra2Data = @ptrCast(@alignCast(instance_data));
const d: *Ssimulacra2Data = @ptrCast(@alignCast(instance_data));
vsapi.?.freeNode.?(d.node1);
vsapi.?.freeNode.?(d.node2);
allocator.destroy(d);
Expand All @@ -186,7 +186,7 @@ export fn ssimulacra2Create(in: ?*const vs.Map, out: ?*vs.Map, user_data: ?*anyo

d.node1 = vsapi.?.mapGetNode.?(in, "reference", 0, &err).?;
d.node2 = vsapi.?.mapGetNode.?(in, "distorted", 0, &err).?;
var vi: *const vs.VideoInfo = vsapi.?.getVideoInfo.?(d.node1);
const vi: *const vs.VideoInfo = vsapi.?.getVideoInfo.?(d.node1);

if (!(vsh.isSameVideoInfo(vi, vsapi.?.getVideoInfo.?(d.node2)))) {
vsapi.?.mapSetError.?(out, "SSIMULACRA2: both clips must have the same format and dimensions.");
Expand All @@ -202,7 +202,7 @@ export fn ssimulacra2Create(in: ?*const vs.Map, out: ?*vs.Map, user_data: ?*anyo
return;
}

var data: *Ssimulacra2Data = allocator.create(Ssimulacra2Data) catch unreachable;
const data: *Ssimulacra2Data = allocator.create(Ssimulacra2Data) catch unreachable;
data.* = d;

var deps = [_]vs.FilterDependency{
Expand Down
6 changes: 3 additions & 3 deletions src/xyb.zig
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ inline fn make_positive_xyb(xyb: *[3]vec_t) void {

inline fn process_vec(src: [3][]const f32, dst: [3][]f32) void {
var out: [3]vec_t = undefined;
var rgb = [3]vec_t{
const rgb = [3]vec_t{
src[0][0..16].*,
src[1][0..16].*,
src[2][0..16].*,
Expand All @@ -150,13 +150,13 @@ pub inline fn process(_srcp: [3][*]const f32, _dstp: [3][*]f32, stride: usize, w
var x: usize = 0;
while (x < width) : (x += 16) {
const x2: usize = x + 16;
var srcps = [3][]const f32{
const srcps = [3][]const f32{
srcp[0][x..x2],
srcp[1][x..x2],
srcp[2][x..x2],
};

var dstps = [3][]f32{
const dstps = [3][]f32{
dstp[0][x..x2],
dstp[1][x..x2],
dstp[2][x..x2],
Expand Down

0 comments on commit 5d6e8e7

Please sign in to comment.