diff --git a/src/transform.zig b/src/transform.zig index 8d85a9c..6d539c2 100644 --- a/src/transform.zig +++ b/src/transform.zig @@ -16,16 +16,15 @@ inline fn dct_coeff(u: usize, v: usize) f16 { inline fn zz_conv(u: usize, v: usize) struct { u: usize, v: usize } { var band_i = u + v; - const band_max_u = @min(7, band_i); - const band_max_v = @min(7, band_i); + const band_max = @min(7, band_i); var idx: usize = 0; for (0..band_i) |i| { idx += zz_band_len(i); } if (band_i % 2 == 0) { - idx += band_max_v - v; + idx += band_max - v; } else { - idx += band_max_u - u; + idx += band_max - u; } return .{ .u = idx / 8, @@ -45,7 +44,7 @@ fn gen_coeffs() [8][8]@Vector(64, f16) { const zz_idx = zz_conv(u, v); for (0..8) |x| { for (0..8) |y| { - ret[zz_idx.u][zz_idx.v][x * 8 + y] = dct_coeff(zz_idx.u, zz_idx.v) * dct_cos(x, zz_idx.u) * dct_cos(y, zz_idx.v); + ret[zz_idx.u][zz_idx.v][y * 8 + x] = dct_coeff(u, v) * dct_cos(x, u) * dct_cos(y, v); } } }