add way to detect all blocks processed for img

This commit is contained in:
Muaz Ahmad 2023-11-27 16:46:38 +05:00
parent f8847be2fb
commit 00e800cec0
2 changed files with 5 additions and 1 deletions

View file

@ -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_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.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); 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) {}
} }

View file

@ -69,6 +69,8 @@ pub const Buffers = struct {
U_quant: [][]BlockQuantized, U_quant: [][]BlockQuantized,
V_quant: [][]BlockQuantized, V_quant: [][]BlockQuantized,
num_blocks: u32,
input_buff: []u8, input_buff: []u8,
output_buff: []u8, output_buff: []u8,
@ -90,6 +92,8 @@ pub const Buffers = struct {
.U_quant = try alloc.alloc([]BlockQuantized, block_h), .U_quant = try alloc.alloc([]BlockQuantized, block_h),
.V_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), .input_buff = try alloc.alloc(u8, w * 8),
.output_buff = try alloc.alloc(u8, output_buff_len), .output_buff = try alloc.alloc(u8, output_buff_len),
}; };