33 #define LZW_MAXBITS 12 34 #define LZW_SIZTABLE (1<<LZW_MAXBITS) 35 #define LZW_HASH_SIZE 16411 36 #define LZW_HASH_SHIFT 6 38 #define LZW_PREFIX_EMPTY -1 39 #define LZW_PREFIX_FREE -2 75 static inline int hash(
int head,
const int add)
174 for (i = 0; i < 256; i++) {
238 for (i = 0; i < insize; i++) {
269 lzw_flush_put_bits(&s->
pb);
int hash_prefix
Hash code of prefix, LZW_PREFIX_EMPTY if empty prefix, or LZW_PREFIX_FREE if no code.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
int bufsize
Size of output buffer.
static int hash(int head, const int add)
Hash function adding character.
static void addCode(LZWEncodeState *s, uint8_t c, int hash_prefix, int hash_code)
Add block to LZW code table.
int end_code
Value of end code.
int maxbits
Max bits code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void clearTable(LZWEncodeState *s)
Clear LZW code table.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
int ff_lzw_encode_flush(LZWEncodeState *s, void(*lzw_flush_put_bits)(PutBitContext *))
Write end code and flush bitstream.
PutBitContext pb
Put bit context for output.
int tabsize
Number of values in hash table.
int clear_code
Value of clear code.
static int writtenBytes(LZWEncodeState *s)
Calculate number of bytes written.
static const uint8_t offset[127][2]
int last_code
Value of last output code or LZW_PREFIX_EMPTY.
static int put_bits_count(PutBitContext *s)
int ff_lzw_encode(LZWEncodeState *s, const uint8_t *inbuf, int insize)
LZW main compress function.
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.
uint8_t suffix
Last character in code block.
int maxcode
Max value of code.
Libavcodec external API header.
typedef void(RENAME(mix_any_func_type))
enum FF_LZW_MODES mode
TIFF or GIF.
int bits
Actual bits code.
void(* put_bits)(PutBitContext *, int, unsigned)
GIF is LE while TIFF is BE.
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
int output_bytes
Number of written bytes.
static const struct twinvq_data tab
static int hashNext(int head, const int offset)
Hash function calculates next hash value.
const int ff_lzw_encode_state_size
mode
Use these values in ebur128_init (or'ed).
static int hashOffset(const int head)
Hash function calculates hash offset.
void ff_lzw_encode_init(LZWEncodeState *s, uint8_t *outbuf, int outsize, int maxbits, enum FF_LZW_MODES mode, void(*lzw_put_bits)(PutBitContext *, int, unsigned))
Initialize LZW encoder.
Code tab[LZW_HASH_SIZE]
Hash table.