lzwenc.c File Reference


Detailed Description

LZW encoder.

Author:
Bartlomiej Wolowiec

Definition in file lzwenc.c.

Go to the source code of this file.

Classes

struct  Code
 One code in hash table. More...
struct  LZWEncodeState
 LZW encode state. More...

Functions

static int hash (int head, const int add)
 Hash function adding character.
static int hashNext (int head, const int offset)
 Hash function calculates next hash value.
static int hashOffset (const int head)
 Hash function calculates hash offset.
static void writeCode (LZWEncodeState *s, int c)
 Write one code to stream.
static int findCode (LZWEncodeState *s, uint8_t c, int hash_prefix)
 Find LZW code for block.
static void addCode (LZWEncodeState *s, uint8_t c, int hash_prefix, int hash_code)
 Add block to LZW code table.
static void clearTable (LZWEncodeState *s)
 Clear LZW code table.
static int writtenBytes (LZWEncodeState *s)
 Calculate number of bytes written.
void ff_lzw_encode_init (LZWEncodeState *s, uint8_t *outbuf, int outsize, int maxbits)
 Initialize LZW encoder.
int ff_lzw_encode (LZWEncodeState *s, const uint8_t *inbuf, int insize)
 LZW main compress function.
int ff_lzw_encode_flush (LZWEncodeState *s)
 Write end code and flush bitstream.

Variables

const int ff_lzw_encode_state_size = sizeof(LZWEncodeState)


Function Documentation

static int hash ( int  head,
const int  add 
) [inline, static]

Hash function adding character.

Parameters:
head LZW code for prefix
add Character to add
Returns:
New hash value

Definition at line 72 of file lzwenc.c.

Referenced by clearTable(), ff_lzw_encode(), and findCode().

static int hashNext ( int  head,
const int  offset 
) [inline, static]

Hash function calculates next hash value.

Parameters:
head Actual hash code
offset Offset calculated by hashOffset
Returns:
New hash value

Definition at line 87 of file lzwenc.c.

Referenced by findCode().

static int hashOffset ( const int  head  )  [inline, static]

Hash function calculates hash offset.

Parameters:
head Actual hash code
Returns:
Hash offset

Definition at line 100 of file lzwenc.c.

Referenced by findCode().

static void writeCode ( LZWEncodeState s,
int  c 
) [inline, static]

Write one code to stream.

Parameters:
s LZW state
c code to write

Definition at line 110 of file lzwenc.c.

Referenced by clearTable(), ff_lzw_encode(), and ff_lzw_encode_flush().

static int findCode ( LZWEncodeState s,
uint8_t  c,
int  hash_prefix 
) [inline, static]

Find LZW code for block.

Parameters:
s LZW state
c Last character in block
hash_prefix LZW code for prefix
Returns:
LZW code for block or -1 if not found in table

Definition at line 124 of file lzwenc.c.

Referenced by ff_lzw_encode().

static void addCode ( LZWEncodeState s,
uint8_t  c,
int  hash_prefix,
int  hash_code 
) [inline, static]

Add block to LZW code table.

Parameters:
s LZW state
c Last character in block
hash_prefix LZW code for prefix
hash_code LZW code for bytes block

Definition at line 146 of file lzwenc.c.

Referenced by ff_lzw_encode().

static void clearTable ( LZWEncodeState s  )  [static]

Clear LZW code table.

Parameters:
s LZW state

Definition at line 162 of file lzwenc.c.

Referenced by ff_lzw_encode().

static int writtenBytes ( LZWEncodeState s  )  [static]

Calculate number of bytes written.

Parameters:
s LZW encode state
Returns:
Number of bytes written

Definition at line 185 of file lzwenc.c.

Referenced by ff_lzw_encode(), and ff_lzw_encode_flush().

void ff_lzw_encode_init ( LZWEncodeState s,
uint8_t *  outbuf,
int  outsize,
int  maxbits 
)

Initialize LZW encoder.

Please set s->clear_code, s->end_code and s->maxbits before run.

Parameters:
s LZW state
outbuf Output buffer
outsize Size of output buffer
maxbits Maximum length of code

Definition at line 199 of file lzwenc.c.

int ff_lzw_encode ( LZWEncodeState s,
const uint8_t *  inbuf,
int  insize 
)

LZW main compress function.

Parameters:
s LZW state
inbuf Input buffer
insize Size of input buffer
Returns:
Number of bytes written or -1 on error

Definition at line 220 of file lzwenc.c.

Referenced by encode_strip().

int ff_lzw_encode_flush ( LZWEncodeState s  ) 

Write end code and flush bitstream.

Parameters:
s LZW state
Returns:
Number of bytes written or -1 on error

Definition at line 253 of file lzwenc.c.


Variable Documentation

Definition at line 64 of file lzwenc.c.


Generated on Sat Dec 18 05:15:53 2010 for MythTV by  doxygen 1.5.5