![]() |
tinyimg 1.0.0
Lightweight image manipulation library for Cloudflare Workers
|
The variable width LZW shared by the GIF and TIFF codecs. More...
#include <stddef.h>#include <stdint.h>Go to the source code of this file.
Classes | |
| struct | TinyLzwTable |
| The dictionary a stream builds as it is read. More... | |
| struct | TinyLzwReader |
| A code stream being read, in either bit order and framing. More... | |
Macros | |
| #define | TINY_LZW_MAX_BITS 12u |
| #define | TINY_LZW_CODES (1u << TINY_LZW_MAX_BITS) |
Functions | |
| void | tiny_lzw_init (TinyLzwReader *reader, const uint8_t *data, size_t size, size_t at, int chained, int msb) |
| Points a reader at a stream. | |
| int | tiny_lzw_expand (TinyLzwReader *reader, TinyLzwTable *table, uint32_t code_bits, int early, uint8_t *out, size_t capacity) |
| Expands a stream into a byte plane. | |
The variable width LZW shared by the GIF and TIFF codecs.
| #define TINY_LZW_CODES (1u << TINY_LZW_MAX_BITS) |
How many codes a dictionary can hold, which is all a twelve bit code names.
| #define TINY_LZW_MAX_BITS 12u |
Codes never exceed twelve bits in either format.
| int tiny_lzw_expand | ( | TinyLzwReader * | reader, |
| TinyLzwTable * | table, | ||
| uint32_t | code_bits, | ||
| int | early, | ||
| uint8_t * | out, | ||
| size_t | capacity ) |
Expands a stream into a byte plane.
Stops at the stream's end code, at the end of the buffer, or when the plane is full, whichever comes first. A stream that stops early leaves the rest of the plane as the caller filled it, which is what lets a truncated file decode the rows that did arrive.
| reader | The reader, positioned at the first code. |
| table | Scratch for the dictionary, which the caller owns. |
| code_bits | Root symbol width, so the first codes are one bit wider. |
| early | Non-zero to widen a code one entry early, which is TIFF's rule. |
| out | Destination plane. |
| capacity | How many bytes the plane holds. |
| void tiny_lzw_init | ( | TinyLzwReader * | reader, |
| const uint8_t * | data, | ||
| size_t | size, | ||
| size_t | at, | ||
| int | chained, | ||
| int | msb ) |
Points a reader at a stream.
| reader | The reader. |
| data | The bytes. |
| size | Number of bytes. |
| at | Offset of the first code. |
| chained | Non-zero when the data is framed in sub-blocks. |
| msb | Non-zero to read most significant bit first. |