expand quant range, fix band_len calc

This commit is contained in:
Muaz Ahmad 2023-11-28 15:02:32 +05:00
parent e50a47398a
commit 1182082c50

View file

@ -55,7 +55,7 @@ pub const JobQueue = struct {
pub fn HasJobs(self: *Self) bool { pub fn HasJobs(self: *Self) bool {
self.mutex.lock(); self.mutex.lock();
defer self.mutex.unlock(); defer self.mutex.unlock();
return (self.queue.len == 0); return (self.queue.len != 0);
} }
}; };
pub const JobPool = std.heap.MemoryPool(JobQueue.List.Node); pub const JobPool = std.heap.MemoryPool(JobQueue.List.Node);
@ -126,11 +126,11 @@ pub const Buffers = struct {
pub fn gen_qtable(q_max: usize, q: f16, band_range: usize) @Vector(64, f16) { pub fn gen_qtable(q_max: usize, q: f16, band_range: usize) @Vector(64, f16) {
var ret: @Vector(64, f16) = [_]f16{0.0} ** 64; var ret: @Vector(64, f16) = [_]f16{0.0} ** 64;
const q_min: usize = @intFromFloat(255 - 100 * q); const q_min: usize = @intFromFloat(255 - 250 * q);
var step = (q_max - q_min) / band_range; var step = (q_max - q_min) / band_range;
var idx: usize = 0; var idx: usize = 0;
for (0..16) |band_i| { for (0..16) |band_i| {
const band_len = band_i + 1; const band_len = if (band_i < 8) band_i + 1 else 15 - band_i;
for (0..band_len) |j| { for (0..band_len) |j| {
if (band_i < band_range) { if (band_i < band_range) {
ret[idx + j] = @floatFromInt(q_min + step * band_i); ret[idx + j] = @floatFromInt(q_min + step * band_i);