XenevaOS
Loading...
Searching...
No Matches
Macros | Typedefs | Enumerations | Functions
lzw.h File Reference

LZW decompression (interface) More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LZW_CODE_MAX   12
 

Typedefs

typedef enum lzw_result lzw_result
 

Enumerations

enum  lzw_result {
  LZW_OK , LZW_OK_EOD , LZW_NO_MEM , LZW_NO_DATA ,
  LZW_EOI_CODE , LZW_NO_COLOUR , LZW_BAD_ICODE , LZW_BAD_PARAM ,
  LZW_BAD_CODE
}
 

Functions

lzw_result lzw_context_create (struct lzw_ctx **ctx)
 
void lzw_context_destroy (struct lzw_ctx *ctx)
 
lzw_result lzw_decode_init (struct lzw_ctx *ctx, uint8_t minimum_code_size, const uint8_t *input_data, size_t input_length, size_t input_pos)
 
lzw_result lzw_decode (struct lzw_ctx *ctx, const uint8_t *restrict *const restrict output_data, uint32_t *restrict output_written)
 
lzw_result lzw_decode_init_map (struct lzw_ctx *ctx, uint8_t minimum_code_size, uint32_t transparency_idx, const uint32_t *colour_table, const uint8_t *input_data, size_t input_length, size_t input_pos)
 
lzw_result lzw_decode_map (struct lzw_ctx *ctx, uint32_t *restrict output_data, uint32_t output_length, uint32_t *restrict output_written)
 

Detailed Description

LZW decompression (interface)

Decoder for GIF LZW data.

Macro Definition Documentation

◆ LZW_CODE_MAX

#define LZW_CODE_MAX   12

Maximum LZW code size in bits

Typedef Documentation

◆ lzw_result

typedef enum lzw_result lzw_result

LZW decoding response codes

Enumeration Type Documentation

◆ lzw_result

enum lzw_result

LZW decoding response codes

Enumerator
LZW_OK 

Success

LZW_OK_EOD 

Success; reached zero-length sub-block

LZW_NO_MEM 

Error: Out of memory

LZW_NO_DATA 

Error: Out of data

LZW_EOI_CODE 

Error: End of Information code

LZW_NO_COLOUR 

Error: No colour map provided.

LZW_BAD_ICODE 

Error: Bad initial LZW code

LZW_BAD_PARAM 

Error: Bad function parameter.

LZW_BAD_CODE 

Error: Bad LZW code

Function Documentation

◆ lzw_context_create()

lzw_result lzw_context_create ( struct lzw_ctx **  ctx)

Create an LZW decompression context.

Parameters
[out]ctxReturns an LZW decompression context. Caller owned, free with lzw_context_destroy().
Returns
LZW_OK on success, or appropriate error code otherwise.

◆ lzw_context_destroy()

void lzw_context_destroy ( struct lzw_ctx *  ctx)

Destroy an LZW decompression context.

Parameters
[in]ctxThe LZW decompression context to destroy.

◆ lzw_decode()

lzw_result lzw_decode ( struct lzw_ctx *  ctx,
const uint8_t *restrict *const restrict  output_data,
uint32_t *restrict  output_written 
)

Read input codes until end of LZW context owned output buffer.

Ensure anything in output is used before calling this, as anything there before this call will be trampled.

Parameters
[in]ctxLZW reading context, updated.
[out]output_dataReturns pointer to array of output values.
[out]output_writtenReturns the number of values written to data.
Returns
LZW_OK on success, or appropriate error code otherwise.

◆ lzw_decode_init()

lzw_result lzw_decode_init ( struct lzw_ctx *  ctx,
uint8_t  minimum_code_size,
const uint8_t *  input_data,
size_t  input_length,
size_t  input_pos 
)

Initialise an LZW decompression context for decoding.

Parameters
[in]ctxThe LZW decompression context to initialise.
[in]minimum_code_sizeThe LZW Minimum Code Size.
[in]input_dataThe compressed data.
[in]input_lengthByte length of compressed data.
[in]input_posStart position in data. Must be position of a size byte at sub-block start.
Returns
LZW_OK on success, or appropriate error code otherwise.

◆ lzw_decode_init_map()

lzw_result lzw_decode_init_map ( struct lzw_ctx *  ctx,
uint8_t  minimum_code_size,
uint32_t  transparency_idx,
const uint32_t *  colour_table,
const uint8_t *  input_data,
size_t  input_length,
size_t  input_pos 
)

Initialise an LZW decompression context for decoding to colour map values.

For transparency to work correctly, the given client buffer must have the values from the previous frame. The transparency_idx should be a value of 256 or above, if the frame does not have transparency.

Parameters
[in]ctxThe LZW decompression context to initialise.
[in]minimum_code_sizeThe LZW Minimum Code Size.
[in]transparency_idxIndex representing transparency.
[in]colour_tableIndex to pixel colour mapping.
[in]input_dataThe compressed data.
[in]input_lengthByte length of compressed data.
[in]input_posStart position in data. Must be position of a size byte at sub-block start.
Returns
LZW_OK on success, or appropriate error code otherwise.

◆ lzw_decode_map()

lzw_result lzw_decode_map ( struct lzw_ctx *  ctx,
uint32_t *restrict  output_data,
uint32_t  output_length,
uint32_t *restrict  output_written 
)

Read LZW codes into client buffer, mapping output to colours.

The context must have been initialised using lzw_decode_init_map before calling this function, in order to provide the colour mapping table and any transparency index.

Ensure anything in output is used before calling this, as anything there before this call will be trampled.

Parameters
[in]ctxLZW reading context, updated.
[in]output_dataClient buffer to fill with colour mapped values.
[in]output_lengthSize of output array.
[out]output_writtenReturns the number of values written to data.
Returns
LZW_OK on success, or appropriate error code otherwise.