diff --git a/src/input.zig b/src/input.zig index a7c84a0..cf90f8e 100644 --- a/src/input.zig +++ b/src/input.zig @@ -60,5 +60,5 @@ pub fn main_loop(f: std.fs.File, buffs: util.Buffers, thread_mgr: threads.Thread try read_lum(f, buffs.Y, buffs.Y_quant, buffs.input_buff, thread_mgr.queue_wrp.queue); try read_chrom(f, buffs.U, buffs.U_quant, buffs.input_buff[0 .. buffs.input_buff.len / 2], thread_mgr.queue_wrp.queue); try read_chrom(f, buffs.V, buffs.V_quant, buffs.input_buff[0 .. buffs.input_buff.len / 2], thread_mgr.queue_wrp.queue); - std.time.sleep(10000000); + while (thread_mgr.signals.processed.load(.Acquire) != buffs.num_blocks) {} } diff --git a/src/util.zig b/src/util.zig index 8f82552..928a2dc 100644 --- a/src/util.zig +++ b/src/util.zig @@ -69,6 +69,8 @@ pub const Buffers = struct { U_quant: [][]BlockQuantized, V_quant: [][]BlockQuantized, + num_blocks: u32, + input_buff: []u8, output_buff: []u8, @@ -90,6 +92,8 @@ pub const Buffers = struct { .U_quant = try alloc.alloc([]BlockQuantized, block_h), .V_quant = try alloc.alloc([]BlockQuantized, block_h), + .num_blocks = @truncate(w * h * 3 / 2 / 64), + .input_buff = try alloc.alloc(u8, w * 8), .output_buff = try alloc.alloc(u8, output_buff_len), };