zigzag order fix
This commit is contained in:
parent
eeb67c3b79
commit
a4c4b1fdcf
1 changed files with 4 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue