Skip to documentation
SLOP

tiny.gif.DecodePlan

Reference tiny.gif DecodePlan

Defined in tiny.gif.

API (12)

Actions

Public operations.

Fields and members

Public fields and members.

No direct callersNo direct callstiny.gifDecodePlan
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/gif/src/decode/plan.zig:15

zig
pub const Plan = struct {    input_bytes: usize,    input_hash: u64,    width: u32,    height: u32,    canvas_pixels: usize,    canvas_rgba8_bytes: usize,    frames: usize,    frame_pixels: usize,    compressed_bytes: usize,    retained_rgba8_bytes: usize,    pub fn inspect(bytes: []const u8, bounds: Bounds) Error!Plan {        var reader = stream.Reader{ .bytes = bytes };        const header = try stream.readHeader(&reader);        const canvas_pixels = try multiplied(header.width, header.height);        if (canvas_pixels > bounds.canvas_pixels) return error.CanvasPixelCapacityExceeded;        const canvas_rgba8_bytes = try multiplied(canvas_pixels, 4);        var frame_count: usize = 0;        var frame_pixels: usize = 0;        var compressed_bytes: usize = 0;        var retained_rgba8_bytes: usize = 0;        var trailer = false;        while (!trailer) {            switch (try reader.byte()) {                0x21 => {                    const label = try reader.byte();                    if (label == 0xf9) {                        _ = try stream.readControl(&reader);                    } else {                        try stream.skipSubBlocks(&reader);                    }                },                0x2c => {                    const descriptor = try stream.readDescriptor(&reader, header.global_table);                    const descriptor_pixels = descriptor.pixelCount();                    if (descriptor_pixels > bounds.frame_pixels) return error.FramePixelCapacityExceeded;                    frame_pixels = @max(frame_pixels, descriptor_pixels);                    frame_count = std.math.add(usize, frame_count, 1) catch return error.CapacityOverflow;                    if (frame_count > bounds.frames) return error.FrameCapacityExceeded;                    const compressed = try stream.readSubBlocks(&reader, null, bounds.compressed_bytes);                    compressed_bytes = @max(compressed_bytes, compressed);                    retained_rgba8_bytes = std.math.add(                        usize,                        retained_rgba8_bytes,                        canvas_rgba8_bytes,                    ) catch return error.CapacityOverflow;                    if (retained_rgba8_bytes > bounds.retained_rgba8_bytes) {                        return error.RetainedRgba8CapacityExceeded;                    }                },                0x3b => trailer = true,                else => return error.InvalidDescriptor,            }        }        if (frame_count == 0) return error.NoFrames;        return .{            .input_bytes = bytes.len,            .input_hash = std.hash.Wyhash.hash(0, bytes),            .width = header.width,            .height = header.height,            .canvas_pixels = canvas_pixels,            .canvas_rgba8_bytes = canvas_rgba8_bytes,            .frames = frame_count,            .frame_pixels = frame_pixels,            .compressed_bytes = compressed_bytes,            .retained_rgba8_bytes = retained_rgba8_bytes,        };    }    pub fn exactBounds(self: Plan) Bounds {        return .{            .canvas_pixels = self.canvas_pixels,            .frame_pixels = self.frame_pixels,            .frames = self.frames,            .compressed_bytes = self.compressed_bytes,            .retained_rgba8_bytes = self.retained_rgba8_bytes,        };    }};

Source: lib/gif/src/root.zig:15

zig
pub const DecodePlan = decode.Plan;
Called byCallsNo direct callersprivate sourcelib.gif.src.decode.planmultipliedprivate sourcelib.gif.src.decode.streamreadControlprivate sourcelib.gif.src.decode.streamreadDescriptorprivate sourcelib.gif.src.decode.streamreadSubBlocksprivate sourcelib.gif.src.decode.streamskipSubBlocksDecodePlaninspect
Static calls · unresolved targets: 0 · external targets: 3.

Audit

Definitions3
Public names3
Members10
Version26.7.0
Revisiondaab053ee433