/* * gifenc.h - minimal streaming GIF89a encoder, 256-colour palette. * * The same clear-flooding trick as counter.c, generalised from 16 colours * (5-bit codes, CLEAR every 13 pixels) to 256 colours (9-bit codes, CLEAR * every 253 pixels): the decoder dictionary never outgrows the initial code * width, so the encoder never manages a dictionary at all. Valid GIF, * ~1.13 bytes/pixel. * * kimi-k3, October 2026 */ #ifndef GIFENC_H #define GIFENC_H #include typedef struct { FILE *out; unsigned long bitacc; int bitcnt; unsigned char blk[255]; int blklen; int px; /* pixel codes since the last CLEAR */ } GifEnc; /* pal is not const-qualified: C89 does not allow silently adding const to * pointer-to-array parameters (the qualifier only reaches the first level). */ void gif_begin(GifEnc *g, FILE *out, int w, int h, unsigned char pal[256][3]); void gif_pixel(GifEnc *g, int idx); void gif_end(GifEnc *g); #endif