|
LibTIFF 4.7.2
TIFF library public API and implementation reference
|
Implement TIFF LZW encoding standard decoding and legacy decoding. More...
#include "tiffiop.h"#include "tif_predict.h"#include <stdbool.h>#include <stdio.h>#include <stdlib.h>Go to the source code of this file.
Data Structures | |
| struct | LZWBaseState |
| Prefix LZW state with Predictor hooks and shared bit-code state. More... | |
| struct | hash_t |
| Pair an encoder hash key with its dictionary code. More... | |
| struct | code_ent |
| Link one decoder string to its preceding dictionary string. More... | |
| struct | LZWCodecState |
| Own LZW dictionaries hash storage and transfer restart state. More... | |
Macros | |
| #define | SIZEOF_WORDTYPE SIZEOF_SIZE_T |
| Size in bytes of WordType, the decoder bit-buffer word. | |
| #define | LZW_COMPAT /* include backwards compatibility code */ |
| Include decoding of historical reversed-bit-order LZW data. | |
| #define | MAXCODE(n) ((1 << (n)) - 1) |
| Compute the inclusive maximum code for a valid bit width. | |
| #define | BITS_MIN 9 /* start with 9 bits */ |
| Initial and post-clear code width: 9 bits. | |
| #define | BITS_MAX 12 /* max of 12 bit strings */ |
| Maximum code width allowed by TIFF LZW: 12 bits. | |
| #define | CODE_CLEAR 256 /* code to clear string table */ |
| Reserved code 256 that resets the string table. | |
| #define | CODE_EOI 257 /* end-of-information code */ |
| Reserved code 257 that ends the strip or tile. | |
| #define | CODE_FIRST 258 /* first free code entry */ |
| First dictionary code assigned to a new string: 258. | |
| #define | CODE_MAX MAXCODE(BITS_MAX) |
| Largest 12-bit code: MAXCODE(BITS_MAX), i.e. 4095. | |
| #define | HSIZE 9001 /* 91% occupancy */ |
| Number of entries in the encoder hash table: 9001. | |
| #define | HSHIFT (13 - 8) |
| Left shift applied to the input byte when hashing encoder strings. | |
| #define | CSIZE (MAXCODE(BITS_MAX) + 1024L) |
| Number of entries allocated for the decoder string table. | |
| #define | lzw_nbits base.nbits |
| Member alias for base.nbits, the current code width. | |
| #define | lzw_maxcode base.maxcode |
| Member alias for base.maxcode, the largest code at this width. | |
| #define | lzw_free_ent base.free_ent |
| Member alias for base.free_ent, the next free dictionary code. | |
| #define | lzw_nextdata base.nextdata |
| Member alias for base.nextdata, the buffered code bits. | |
| #define | lzw_nextbits base.nextbits |
| Member alias for base.nextbits, the number of buffered bits. | |
| #define | CHECK_GAP 10000 |
| Encoder input bytes between compression-ratio checks: 10000. | |
| #define | LZWState(tif) ((LZWBaseState *)(tif)->tif_data) |
| Cast tif->tif_data to the shared LZWBaseState prefix. | |
| #define | LZWDecoderState(tif) ((LZWCodecState *)LZWState(tif)) |
| Cast tif->tif_data to the full LZWCodecState for decoding. | |
| #define | LZWEncoderState(tif) ((LZWCodecState *)LZWState(tif)) |
| Cast tif->tif_data to the full LZWCodecState for encoding. | |
| #define | GetNextData(nextdata, bp) |
| Load SIZEOF_WORDTYPE bytes at bp into nextdata, first byte most significant. | |
| #define | GetNextCodeLZW() |
| Extract the next nbits-wide MSB-first code from the decoder bit cache into code, refilling from bp as needed. | |
| #define | NextCode(_tif, _sp, _bp, _code, _get, dec_bitsleft) |
| Fetch the next compatibility-mode code with _get, or yield CODE_EOI with a warning when fewer than nbits input bits remain. | |
| #define | GetNextCodeCompat(sp, bp, code) |
| Extract the next nbits-wide LSB-first code for old reversed-order LZW data. | |
| #define | CALCRATIO(sp, rat) |
| Compute the encoder compression ratio incount/outcount as a 24.8 fixed-point value into rat. | |
| #define | PutNextCode(op, c) |
| Append the nbits-wide code c MSB-first to the encoder output at op. | |
Typedefs | |
| typedef size_t | WordType |
| Select the native size_t word for buffered LZW bits. | |
| typedef uint16_t | hcode_t |
| Store an encoder dictionary code in sixteen bits. | |
| typedef struct code_ent | code_t |
| Link one decoder string to its preceding dictionary string. | |
| typedef int(* | decodeFunc) (TIFF *tif, uint8_t *buf, tmsize_t size, uint16_t sample) |
| Signature shared by the LZW decode entry points (recorded in dec_decode). | |
Functions | |
| static int | LZWDecode (TIFF *tif, uint8_t *op0, tmsize_t occ0, uint16_t s) |
| Expand standard TIFF LZW codes into caller output. | |
| static int | LZWDecodeCompat (TIFF *tif, uint8_t *op0, tmsize_t occ0, uint16_t s) |
| Expand historical reversed-order LZW codes into caller output. | |
| static int | LZWFixupTags (TIFF *tif) |
| Accept LZW tag fixup without changes. | |
| static int | LZWSetupDecode (TIFF *tif) |
| Allocate and initialise the LZW decode dictionary. | |
| static int | LZWPreDecode (TIFF *tif, uint16_t s) |
| Reset LZW bit and dictionary state for a strile. | |
| static void | cl_hash (LZWCodecState *sp) |
| Mark every LZW encoder hash slot unused. | |
| static int | LZWSetupEncode (TIFF *tif) |
| Allocate the LZW encoder hash table. | |
| static int | LZWPreEncode (TIFF *tif, uint16_t s) |
| Reset the LZW encoder dictionary bit cache and counters. | |
| static int | LZWEncode (TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) |
| Compress borrowed bytes into buffered TIFF LZW codes. | |
| static int | LZWPostEncode (TIFF *tif) |
| Emit the final LZW string end code and padding bits. | |
| static void | LZWCleanup (TIFF *tif) |
| Release LZW tables and codec state and reset methods. | |
| static uint64_t | LZWGetMaxCompressionRatio (TIFF *tif) |
| Report the empirical LZW expansion heuristic. | |
| int | TIFFInitLZW (TIFF *tif, int scheme) |
| Allocate LZW codec state and install predictor-aware methods. | |
Implement TIFF LZW encoding standard decoding and legacy decoding.
Definition in file tif_lzw.c.