jpg output boiler

This commit is contained in:
Muaz Ahmad 2023-11-28 15:29:57 +05:00
parent 03ee4c04cb
commit 6e27ca09d5
3 changed files with 17 additions and 3 deletions

View file

@ -2,6 +2,7 @@ const std = @import("std");
const util = @import("util.zig");
const threads = @import("threads.zig");
const output = @import("output.zig");
inline fn lum_idxs(i: usize, j: usize) struct { usize, usize, usize } {
return .{
@ -58,12 +59,13 @@ fn read_chrom(f: std.fs.File, source_buff: [][]util.Block, target_buff: [][]util
}
}
pub fn main_loop(f: std.fs.File, buffs: util.Buffers, thread_mgr: *threads.ThreadManager) !void {
pub fn main_loop(f: std.fs.File, buffs: util.Buffers, thread_mgr: *threads.ThreadManager, alloc: std.mem.Allocator) !void {
defer thread_mgr.quit();
thread_mgr.unblock();
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);
while (thread_mgr.signals.processed.load(.Acquire) != buffs.num_blocks) : (std.time.sleep(1)) {}
thread_mgr.eof();
thread_mgr.quit();
try output.generate_jpg(buffs, alloc);
}

View file

@ -65,5 +65,5 @@ pub fn main() !void {
defer thread_manager.deinit();
var f = std.io.getStdIn();
try input.main_loop(f, buffs, &thread_manager);
try input.main_loop(f, buffs, &thread_manager, std.heap.page_allocator);
}

12
src/output.zig Normal file
View file

@ -0,0 +1,12 @@
const std = @import("std");
const util = @import("util.zig");
pub fn generate_jpg(buff: util.Buffers, alloc: std.mem.Allocator) !void {
_ = alloc;
_ = buff;
// rle, huffman pass
// file headers
// quant + huffman write
// write scan
}