|
LibTIFF 4.7.2
TIFF library public API and implementation reference
|
Implement Group3 Group4 and aligned modified-Huffman fax coding. More...
Go to the source code of this file.
Data Structures | |
| struct | Fax3BaseState |
| Prefix fax state with geometry options and saved method chains. More... | |
| struct | Fax3CodecState |
| Own fax run/reference buffers and bit-stream progress. More... | |
Macros | |
| #define | G3CODES |
| Instantiate the Huffman code tables from t4.h. | |
| #define | EOF_REACHED_COUNT_THRESHOLD 8192 |
| Limit repeated fax recovery conditions per strile. | |
| #define | Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data) |
| Borrow the shared fax state prefix. | |
| #define | DecoderState(tif) ((Fax3CodecState *)Fax3State(tif)) |
| Borrow the complete fax decoder state. | |
| #define | EncoderState(tif) ((Fax3CodecState *)Fax3State(tif)) |
| Borrow the complete fax encoder state. | |
| #define | is2DEncoding(sp) (sp->b.groupoptions & GROUP3OPT_2DENCODING) |
| Test Group3 two-dimensional mode. | |
| #define | isAligned(p, t) ((((size_t)(p)) & (sizeof(t) - 1)) == 0) |
| Test a pointer against a type-sized alignment. | |
| #define | DECLARE_STATE(tif, sp, mod) |
| Declare cached local one-dimensional decode state. | |
| #define | DECLARE_STATE_2D(tif, sp, mod) |
| Declare local two-dimensional decode and reference state. | |
| #define | CACHE_STATE(tif, sp) |
| Load codec and raw cursor state into decode locals. | |
| #define | UNCACHE_STATE(tif, sp) |
| Commit local bit state and consumed raw bytes. | |
| #define | unexpected(table, a0) |
| Diagnose a bad code and increment its recovery counter. | |
| #define | extension(a0) Fax3Extension(module, tif, (uint32_t)sp->line, (uint32_t)(a0)) |
| Diagnose an unsupported uncompressed extension. | |
| #define | badlength(a0, lastx) |
| Warn about row width and increment its recovery counter. | |
| #define | prematureEOF(a0) |
| Warn about input exhaustion and increment its recovery counter. | |
| #define | tryG3WithoutEOL(a0) |
| Warn about retrying Group3 data without EOL. | |
| #define | SWAP(t, a, b) |
| Exchange current and reference run-array pointers. | |
| #define | FILL(n, cp) |
| Set complete black output bytes and advance the pointer. | |
| #define | ZERO(n, cp) |
| Clear complete white output bytes and advance the pointer. | |
| #define | Fax3FlushBits(tif, sp) |
| Append a partial code byte and flush raw output when full. | |
| #define | _FlushBits(tif) |
| Append local code bits and reset local byte state. | |
| #define | _PutBits(tif, bits, length) |
| Append local code bits across partial-byte boundaries. | |
| #define | putcode(tif, te) Fax3PutBits(tif, (te)->code, (te)->length) |
| Emit one Huffman table entry. | |
| #define | finddiff(_cp, _bs, _be, _color) (_bs + (_color ? find1span(_cp, _bs, _be) : find0span(_cp, _bs, _be))) |
| Find the next pixel differing from the selected colour. | |
| #define | finddiff2(_cp, _bs, _be, _color) (_bs < _be ? finddiff(_cp, _bs, _be, _color) : _be) |
| Find a change while bounding an already exhausted start. | |
| #define | PIXEL(buf, ix) ((((buf)[(ix) >> 3]) >> (7 - ((ix) & 7))) & 1) |
| Read one MSB-first packed pixel bit. | |
| #define | FIELD_BADFAXLINES (FIELD_CODEC + 0) |
| Reserve the BadFaxLines codec field bit. | |
| #define | FIELD_CLEANFAXDATA (FIELD_CODEC + 1) |
| Reserve the CleanFaxData codec field bit. | |
| #define | FIELD_BADFAXRUN (FIELD_CODEC + 2) |
| Reserve the consecutive-bad-lines codec field bit. | |
| #define | FIELD_OPTIONS (FIELD_CODEC + 7) |
| Reserve the Group3/4 options codec field bit. | |
| #define | SWAP(t, a, b) |
| Exchange current and reference run-array pointers. | |
Enumerations | |
| enum | Ttag { G3_1D , G3_2D } |
| Select the next Group3 encoded row dimensionality. More... | |
Functions | |
| static int | Fax3PreDecode (TIFF *tif, uint16_t s) |
| Reset fax bit state run pointers and recovery counters. | |
| static void | Fax3Unexpected (const char *module, TIFF *tif, uint32_t line, uint32_t a0) |
| Diagnose an invalid fax code word. | |
| static void | Fax3Extension (const char *module, TIFF *tif, uint32_t line, uint32_t a0) |
| Diagnose unsupported fax uncompressed extension data. | |
| static void | Fax3BadLength (const char *module, TIFF *tif, uint32_t line, uint32_t a0, uint32_t lastx) |
| Warn about a fax row-length mismatch. | |
| static void | Fax3PrematureEOF (const char *module, TIFF *tif, uint32_t line, uint32_t a0) |
| Warn about premature fax input exhaustion. | |
| static void | Fax3TryG3WithoutEOL (const char *module, TIFF *tif, uint32_t line, uint32_t a0) |
| Warn that Group3 recovery will retry without EOL. | |
| static int | CheckReachedCounters (TIFF *tif, const char *module, Fax3CodecState *sp) |
| Stop fax recovery after repeated EOF EOL or bad-code conditions. | |
| static void | Fax3ClearUnwritten (int has_buf, uint8_t *buf, tmsize_t occ) |
| Zero the part of the caller buffer the decoder will not write. | |
| static int | Fax3Decode1D (TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s) |
| Decode complete Group3 one-dimensional fax rows. | |
| static int | Fax3Decode2D (TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s) |
| Decode complete Group3 mixed-dimensional fax rows. | |
| void | _TIFFFax3fillruns (unsigned char *buf, uint32_t *runs, uint32_t *erun, uint32_t lastx) |
| Render alternating white/black fax runs into an MSB-first row. | |
| static int | Fax3FixupTags (TIFF *tif) |
| Accept fax tag fixup without changes. | |
| static int | Fax3SetupState (TIFF *tif) |
| Validate bilevel geometry and allocate fax run/reference storage. | |
| static int | Fax3PutBits (TIFF *tif, unsigned int bits, unsigned int length) |
| Append up to sixteen significant fax code bits. | |
| static int | putspan (TIFF *tif, int32_t span, const tableentry *tab) |
| Emit makeup and terminating Huffman codes for one fax run. | |
| static int | Fax3PutEOL (TIFF *tif) |
| Append Group3 EOL padding and optional dimensional tag. | |
| static int | Fax3PreEncode (TIFF *tif, uint16_t s) |
| Reset fax encoding bits reference line and dimensional schedule. | |
| static int32_t | find0span (unsigned char *bp, int32_t bs, int32_t be) |
| Measure the leading zero bit run in a bounded packed row. | |
| static int32_t | find1span (unsigned char *bp, int32_t bs, int32_t be) |
| Measure the leading one bit run in a bounded packed row. | |
| static int | Fax3Encode1DRow (TIFF *tif, unsigned char *bp, uint32_t bits) |
| Encode alternating white and black runs for one bilevel row. | |
| static int | Fax3Encode2DRow (TIFF *tif, unsigned char *bp, unsigned char *rp, uint32_t bits) |
| Encode one bilevel row relative to its reference row. | |
| static int | Fax3Encode (TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) |
| Encode complete Group3 or aligned RLE rows. | |
| static int | Fax3PostEncode (TIFF *tif) |
| Pad and buffer the final partial fax code byte. | |
| static int | _Fax3Close (TIFF *tif) |
| Append an optional six-EOL fax return-to-control sequence. | |
| static void | Fax3Close (TIFF *tif) |
| Invoke fax return-to-control completion without a status channel. | |
| static void | Fax3Cleanup (TIFF *tif) |
| Restore fax tag/print methods and release run/reference state. | |
| static int | Fax3VSetField (TIFF *tif, uint32_t tag, va_list ap) |
| Assign fax pseudo-tags or persistent fax metadata. | |
| static int | Fax3VGetField (TIFF *tif, uint32_t tag, va_list ap) |
| Retrieve fax mode callback or persistent fax values. | |
| static void | Fax3PrintDir (TIFF *tif, FILE *fd, long flags) |
| Print present fax values then chain the saved directory printer. | |
| static uint64_t | Fax3GetMaxCompressionRatio (TIFF *tif) |
| Report the fax expansion allocation heuristic. | |
| static int | InitCCITTFax3 (TIFF *tif) |
| Allocate shared fax state and install tag and transfer methods. | |
| int | TIFFInitCCITTFax3 (TIFF *tif, int scheme) |
| Install CCITTFax3 fax callbacks and default mode. | |
| static int | Fax4Decode (TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s) |
| Decode complete Group4 two-dimensional fax rows. | |
| static int | Fax4Encode (TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) |
| Encode complete Group4 rows relative to the preceding row. | |
| static int | Fax4PostEncode (TIFF *tif) |
| Append Group4 EOFB and align the final byte. | |
| static uint64_t | Fax4GetMaxCompressionRatio (TIFF *tif) |
| Report the fax expansion allocation heuristic. | |
| int | TIFFInitCCITTFax4 (TIFF *tif, int scheme) |
| Install CCITTFax4 fax callbacks and default mode. | |
| static int | Fax3DecodeRLE (TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s) |
| Decode complete aligned modified-Huffman fax rows. | |
| static uint64_t | Fax3RLEGetMaxCompressionRatio (TIFF *tif) |
| Report the fax expansion allocation heuristic. | |
| int | TIFFInitCCITTRLE (TIFF *tif, int scheme) |
| Install CCITTRLE fax callbacks and default mode. | |
| int | TIFFInitCCITTRLEW (TIFF *tif, int scheme) |
| Install CCITTRLEW fax callbacks and default mode. | |
Variables | |
| static const int | _msbmask [9] |
| Mask the requested low bit count for encoder code packing. | |
| static const unsigned char | zeroruns [256] |
| Count leading zero bits in each byte. | |
| static const unsigned char | oneruns [256] |
| Count leading one bits in each byte. | |
| static const tableentry | horizcode = {3, 0x1, 0} |
| Encode the Group4 horizontal mode prefix. | |
| static const tableentry | passcode = {4, 0x1, 0} |
| Encode the Group4 pass mode prefix. | |
| static const tableentry | vcodes [7] |
| Encode Group4 vertical offsets minus three through three. | |
| static const TIFFField | faxFields [] |
| Define common fax metadata and pseudo-tags. | |
| static const TIFFField | fax3Fields [] |
| Define Group3 options metadata. | |
| static const TIFFField | fax4Fields [] |
| Define Group4 options metadata. | |
Implement Group3 Group4 and aligned modified-Huffman fax coding.
Definition in file tif_fax3.c.