libmobi
C library for handling MOBI format ebook documents
Data Structures | Macros | Functions
compression.h File Reference
#include "config.h"
#include "mobi.h"

Go to the source code of this file.

Data Structures

struct  MOBIHuffCdic
 Parsed data from HUFF and CDIC records needed to unpack huffman compressed text. More...
 

Macros

#define MOBI_INLINE
 
#define MOBI_HUFFMAN_MAXDEPTH   20
 
#define HUFF_CODETABLE_SIZE   33
 

Functions

MOBI_RET mobi_decompress_lz77 (unsigned char *out, const unsigned char *in, size_t *len_out, const size_t len_in)
 Decompressor fo PalmDOC version of LZ77 compression. More...
 
MOBI_RET mobi_decompress_huffman (unsigned char *out, const unsigned char *in, size_t *len_out, size_t len_in, const MOBIHuffCdic *huffcdic)
 Decompressor for huff/cdic compressed text records. More...
 

Detailed Description

Copyright (c) 2014 Bartek Fabiszewski http://www.fabiszewski.net

This file is part of libmobi. Licensed under LGPL, either version 3, or any later. See http://www.gnu.org/licenses/

Macro Definition Documentation

◆ HUFF_CODETABLE_SIZE

#define HUFF_CODETABLE_SIZE   33

Size of min- and maxcode tables

◆ MOBI_HUFFMAN_MAXDEPTH

#define MOBI_HUFFMAN_MAXDEPTH   20

Maximal recursion level for huffman decompression routine

◆ MOBI_INLINE

#define MOBI_INLINE

Syntax for compiler inline keyword from config.h

Function Documentation

◆ mobi_decompress_huffman()

MOBI_RET mobi_decompress_huffman ( unsigned char *  out,
const unsigned char *  in,
size_t *  len_out,
size_t  len_in,
const MOBIHuffCdic huffcdic 
)

Decompressor for huff/cdic compressed text records.

Decompressor and HUFF/CDIC records parsing based on: perl EBook::Tools::Mobipocket python mobiunpack.py, calibre

Parameters
[out]outDecompressed destination data
[in]inCompressed source data
[in,out]len_outSize of the memory reserved for decompressed data. On return it is set to actual size of decompressed data
[in]len_inSize of compressed data
[in]huffcdicMOBIHuffCdic structure with parsed data from huff/cdic records
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_decompress_lz77()

MOBI_RET mobi_decompress_lz77 ( unsigned char *  out,
const unsigned char *  in,
size_t *  len_out,
const size_t  len_in 
)

Decompressor fo PalmDOC version of LZ77 compression.

Decompressor based on this algorithm: http://en.wikibooks.org/wiki/Data_Compression/Dictionary_compression#PalmDoc

Parameters
[out]outDecompressed destination data
[in]inCompressed source data
[in,out]len_outSize of the memory reserved for decompressed data. On return it is set to actual size of decompressed data
[in]len_inSize of compressed data
Returns
MOBI_RET status code (on success MOBI_SUCCESS)