Skip to documentation
SLOP

tiny.gif.EncodePlan

Reference tiny.gif EncodePlan

Defined in tiny.gif.

API (14)

Actions

Public operations.

Fields and members

Public fields and members.

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

Source

Source: lib/gif/src/encode/plan.zig:13

zig
pub const Plan = struct {    input_hash: u64,    width: u32,    height: u32,    canvas_pixels: usize,    frames: usize,    palette_entries: usize,    table_entries: usize,    max_compressed_bytes: usize,    output_bytes: usize,    bounds: Bounds,    palette: model.Palette,    pub fn inspect(        animation: model.AnimationView,        bounds: Bounds,        scratch: *lzw.Scratch,    ) Error!Plan {        return inspectDictionary(animation, bounds, scratch.dictionary());    }    pub fn inspectDictionary(        animation: model.AnimationView,        bounds: Bounds,        dictionary: lzw.Dictionary,    ) Error!Plan {        if (animation.width == 0 or animation.height == 0) return error.InvalidDimensions;        if (animation.width > std.math.maxInt(u16) or animation.height > std.math.maxInt(u16)) {            return error.InvalidDimensions;        }        if (animation.frames.len == 0) return error.NoFrames;        const canvas_pixels = try multiplied(animation.width, animation.height);        if (canvas_pixels > bounds.canvas_pixels) return error.CanvasPixelCapacityExceeded;        if (animation.frames.len > bounds.frames) return error.FrameCapacityExceeded;        const rgba8_bytes = try multiplied(canvas_pixels, 4);        for (animation.frames) |frame| {            if (frame.rgba8.len != rgba8_bytes) return error.FrameSizeMismatch;        }        const palette = try model.Palette.build(animation.frames);        const palette_entries = palette.entryCount();        if (palette_entries > bounds.palette_entries) return error.PaletteCapacityExceeded;        const table_entries = palette.tableEntries();        var output_bytes = try added(13, try multiplied(table_entries, 3));        if (animation.loop_count != null) output_bytes = try added(output_bytes, 19);        var max_compressed_bytes: usize = 0;        for (animation.frames) |frame| {            const source = model.PixelSource{ .palette = &palette, .rgba8 = frame.rgba8 };            const compressed = try lzw.measureSource(palette.minCodeSize(), source, dictionary);            max_compressed_bytes = @max(max_compressed_bytes, compressed);            output_bytes = try added(output_bytes, try frameBytes(compressed));        }        output_bytes = try added(output_bytes, 1);        return .{            .input_hash = animationHash(animation),            .width = animation.width,            .height = animation.height,            .canvas_pixels = canvas_pixels,            .frames = animation.frames.len,            .palette_entries = palette_entries,            .table_entries = table_entries,            .max_compressed_bytes = max_compressed_bytes,            .output_bytes = output_bytes,            .bounds = bounds,            .palette = palette,        };    }    pub fn exactBounds(self: Plan) Bounds {        return .{            .canvas_pixels = self.canvas_pixels,            .frames = self.frames,            .palette_entries = self.palette_entries,        };    }};

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

zig
pub const EncodePlan = encode.Plan;
Called byCallsNo direct callersEncodePlaninspectDictionaryEncodePlaninspect
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsEncodePlaninspectprivate sourcelib.gif.src.encode.model.Palettebuildprivate sourcelib.gif.src.encode.planaddedprivate sourcelib.gif.src.encode.plananimationHashprivate sourcelib.gif.src.encode.planframeBytesprivate sourcelib.gif.src.encode.planmultipliedEncodePlaninspectDictionary
Static calls · unresolved targets: 0 · external targets: 4.

Audit

Definitions4
Public names4
Members11
Version26.7.0
Revisiondaab053ee433