w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pts_lzw.c File Reference
#include <stdlib.h>
#include <string.h>
#include "pts_lzw.h"
#include <assert.h>
#include <stdio.h>
Include dependency graph for pts_lzw.c:

Go to the source code of this file.

Classes

struct  LZWBaseState
 
struct  code_ent
 
struct  LZWDecodeState
 
struct  hash_t
 
struct  LZWEncodeState
 

Macros

#define DUMMY
 
#define LZW_SUPPORT   1
 
#define TO_RDONLY   1
 
#define _TIFFmalloc   malloc
 
#define _TIFFfree   free
 
#define _TIFFmemset   memset
 
#define TIFF_VERSION   42
 
#define TIFFLIB_VERSION   19970127 /* January 27, 1997 */
 
#define NULL   0
 
#define LZW_COMPAT   /* include backwards compatibility code */
 
#define LZW_CHECKEOS   /* include checks for strips w/o EOI code */
 
#define MAXCODE(n)   ((1L<<(n))-1)
 
#define BITS_MIN   9 /* start with 9 bits */
 
#define BITS_MAX   12 /* max of 12 bit strings */
 
#define CODE_CLEAR   256 /* code to clear string table */
 
#define CODE_EOI   257 /* end-of-information code */
 
#define CODE_FIRST   258 /* first free code entry */
 
#define CODE_MAX   MAXCODE(BITS_MAX)
 
#define HSIZE   9001L /* 91% occupancy */
 
#define HSHIFT   (13-8)
 
#define CSIZE   (MAXCODE(BITS_MAX)+1024L)
 
#define lzw_nbits   base.nbits
 
#define lzw_maxcode   base.maxcode
 
#define lzw_free_ent   base.free_ent
 
#define lzw_nextdata   base.nextdata
 
#define lzw_nextbits   base.nextbits
 
#define CHECK_GAP   10000 /* enc_ratio check interval */
 
#define LZWState(tif)   ((LZWBaseState*) (void*) (tif)->tif_data)
 
#define DecoderState(tif)   ((LZWDecodeState*)(void*) LZWState(tif))
 
#define EncoderState(tif)   ((LZWEncodeState*)(void*) LZWState(tif))
 
#define CALCRATIO(sp, rat)
 
#define PutNextCode(op, c)
 
#define _POSIX_SOURCE   1
 
#define _POSIX_C_SOURCE   2
 

Typedefs

typedef struct pts_lzw_state TIFF
 
typedef struct code_ent code_t
 
typedef int(* decodeFunc) (TIFF *, tidataval_t *, tsize_t)
 
typedef unsigned short hcode_t
 

Functions

static int TIFFInitLZW (TIFF *)
 
static void TIFFError (char const *a, char const *b)
 
static int TIFFAppendTo (TIFF *, tidataval_t *, tsize_t)
 
static int TIFFFlushData1 (TIFF *tif)
 
static void cl_hash (LZWEncodeState *)
 
static int LZWSetupEncode (TIFF *tif)
 
static int LZWPreEncode (TIFF *tif)
 
static int LZWEncode (TIFF *tif, tidataval_t *bp, tsize_t cc)
 
static int LZWPostEncode (TIFF *tif)
 
static void LZWCleanup (TIFF *tif)
 
static int feeder (char *readbuf, unsigned readlen, TIFF *tif)
 
int pts_lzw_init (TIFF *tif)
 

Macro Definition Documentation

◆ _POSIX_C_SOURCE

#define _POSIX_C_SOURCE   2

Definition at line 1240 of file pts_lzw.c.

◆ _POSIX_SOURCE

#define _POSIX_SOURCE   1

Definition at line 1238 of file pts_lzw.c.

◆ _TIFFfree

#define _TIFFfree   free

Definition at line 100 of file pts_lzw.c.

◆ _TIFFmalloc

#define _TIFFmalloc   malloc

Definition at line 99 of file pts_lzw.c.

◆ _TIFFmemset

#define _TIFFmemset   memset

Definition at line 101 of file pts_lzw.c.

◆ BITS_MAX

#define BITS_MAX   12 /* max of 12 bit strings */

Definition at line 256 of file pts_lzw.c.

◆ BITS_MIN

#define BITS_MIN   9 /* start with 9 bits */

Definition at line 255 of file pts_lzw.c.

◆ CALCRATIO

#define CALCRATIO (   sp,
  rat 
)
Value:
{ \
if (incount > 0x007fffff) { /* NB: shift will overflow */\
rat = outcount >> 8; \
rat = (rat == 0 ? 0x7fffffff : incount/rat); \
} else \
rat = (incount<<8) / outcount; \
}
static size_t outcount
Definition: backend_pdf.c:77

Definition at line 895 of file pts_lzw.c.

◆ CHECK_GAP

#define CHECK_GAP   10000 /* enc_ratio check interval */

Definition at line 334 of file pts_lzw.c.

◆ CODE_CLEAR

#define CODE_CLEAR   256 /* code to clear string table */

Definition at line 258 of file pts_lzw.c.

◆ CODE_EOI

#define CODE_EOI   257 /* end-of-information code */

Definition at line 259 of file pts_lzw.c.

◆ CODE_FIRST

#define CODE_FIRST   258 /* first free code entry */

Definition at line 260 of file pts_lzw.c.

◆ CODE_MAX

#define CODE_MAX   MAXCODE(BITS_MAX)

Definition at line 261 of file pts_lzw.c.

◆ CSIZE

#define CSIZE   (MAXCODE(BITS_MAX)+1024L)

Definition at line 266 of file pts_lzw.c.

◆ DecoderState

#define DecoderState (   tif)    ((LZWDecodeState*)(void*) LZWState(tif))

Definition at line 343 of file pts_lzw.c.

◆ DUMMY

#define DUMMY
Value:
set -ex; \
g++ -DNDEBUG=1 -O3 -ansi -pedantic \
-Wall -W -Wstrict-prototypes -Wtraditional -Wnested-externs -Winline \
-Wpointer-arith -Wbad-function-cast -Wcast-qual -Wmissing-prototypes \
-Wmissing-declarations pts_lzw.c -c; \
exit
char pedantic
Definition: afm2tfm.c:233
#define W
Definition: dtl.h:141
#define c(n)
Definition: gpos-common.c:150
#define cast(t, exp)
Definition: llimits.h:111

Definition at line 1 of file pts_lzw.c.

◆ EncoderState

#define EncoderState (   tif)    ((LZWEncodeState*)(void*) LZWState(tif))

Definition at line 344 of file pts_lzw.c.

◆ HSHIFT

#define HSHIFT   (13-8)

Definition at line 263 of file pts_lzw.c.

◆ HSIZE

#define HSIZE   9001L /* 91% occupancy */

Definition at line 262 of file pts_lzw.c.

◆ LZW_CHECKEOS

#define LZW_CHECKEOS   /* include checks for strips w/o EOI code */

Definition at line 247 of file pts_lzw.c.

◆ LZW_COMPAT

#define LZW_COMPAT   /* include backwards compatibility code */

Definition at line 240 of file pts_lzw.c.

◆ lzw_free_ent

#define lzw_free_ent   base.free_ent

Definition at line 290 of file pts_lzw.c.

◆ lzw_maxcode

#define lzw_maxcode   base.maxcode

Definition at line 289 of file pts_lzw.c.

◆ lzw_nbits

#define lzw_nbits   base.nbits

Definition at line 288 of file pts_lzw.c.

◆ lzw_nextbits

#define lzw_nextbits   base.nextbits

Definition at line 292 of file pts_lzw.c.

◆ lzw_nextdata

#define lzw_nextdata   base.nextdata

Definition at line 291 of file pts_lzw.c.

◆ LZW_SUPPORT

#define LZW_SUPPORT   1

Definition at line 92 of file pts_lzw.c.

◆ LZWState

#define LZWState (   tif)    ((LZWBaseState*) (void*) (tif)->tif_data)

Definition at line 342 of file pts_lzw.c.

◆ MAXCODE

#define MAXCODE (   n)    ((1L<<(n))-1)

Definition at line 250 of file pts_lzw.c.

◆ NULL

#define NULL   0

Definition at line 164 of file pts_lzw.c.

◆ PutNextCode

#define PutNextCode (   op,
  c 
)
Value:
{ \
nextdata = (nextdata << nbits) | c; \
nextbits += nbits; \
*op++ = (unsigned char)(nextdata >> (nextbits-8)); \
nextbits -= 8; \
if (nextbits >= 8) { \
*op++ = (unsigned char)(nextdata >> (nextbits-8)); \
nextbits -= 8; \
} \
outcount += nbits; \
}
register bit_buf_type register int int nbits
Definition: jdhuff.h:156
Definition: sh.h:1226

Definition at line 902 of file pts_lzw.c.

◆ TIFF_VERSION

#define TIFF_VERSION   42

Definition at line 123 of file pts_lzw.c.

◆ TIFFLIB_VERSION

#define TIFFLIB_VERSION   19970127 /* January 27, 1997 */

Definition at line 142 of file pts_lzw.c.

◆ TO_RDONLY

#define TO_RDONLY   1

Definition at line 98 of file pts_lzw.c.

Typedef Documentation

◆ code_t

typedef struct code_ent code_t

◆ decodeFunc

typedef int(* decodeFunc) (TIFF *, tidataval_t *, tsize_t)

Definition at line 304 of file pts_lzw.c.

◆ hcode_t

typedef unsigned short hcode_t

Definition at line 324 of file pts_lzw.c.

◆ TIFF

typedef struct pts_lzw_state TIFF

Definition at line 1 of file pts_lzw.c.

Function Documentation

◆ cl_hash()

static void cl_hash ( LZWEncodeState sp)
static

Definition at line 1121 of file pts_lzw.c.

References hp, HSIZE, i, and sp.

Referenced by LZWEncode(), and LZWPreEncode().

◆ feeder()

static int feeder ( char *  readbuf,
unsigned  readlen,
TIFF tif 
)
static

◆ LZWCleanup()

static void LZWCleanup ( TIFF tif)
static

Definition at line 1143 of file pts_lzw.c.

References _TIFFfree, DecoderState, EncoderState, NULL, tiff::tif_data, and tiff::tif_rawdata.

Referenced by feeder(), pts_lzw_init(), and TIFFInitLZW().

◆ LZWEncode()

◆ LZWPostEncode()

static int LZWPostEncode ( TIFF tif)
static

◆ LZWPreEncode()

static int LZWPreEncode ( TIFF tif)
static

◆ LZWSetupEncode()

static int LZWSetupEncode ( TIFF tif)
static

Definition at line 853 of file pts_lzw.c.

References _TIFFmalloc, assert(), EncoderState, HSIZE, NULL, sp, and TIFFError().

Referenced by pts_lzw_init(), and TIFFInitLZW().

◆ pts_lzw_init()

int pts_lzw_init ( TIFF tif)

◆ TIFFAppendTo()

◆ TIFFError()

static void TIFFError ( char const a,
char const b 
)
static

Definition at line 1265 of file pts_lzw.c.

References a, b, and fprintf.

Referenced by LZWSetupEncode(), TIFFAppendTo(), and TIFFInitLZW().

◆ TIFFFlushData1()

static int TIFFFlushData1 ( TIFF tif)
static

◆ TIFFInitLZW()