22 #include FT_INTERNAL_MEMORY_H 23 #include FT_INTERNAL_STREAM_H 24 #include FT_INTERNAL_DEBUG_H 70 ? (
FT_UInt)( ( 1UL << num_bits ) - 256 )
81 if ( ft_lzwstate_refill( state ) < 0 )
89 p = &state->
buf_tab[offset >> 3];
102 result |= ( *p &
LZW_MASK( num_bits ) ) << offset;
119 new_size = new_size + ( new_size >> 1 ) + 4;
132 if ( new_size == old_size )
158 new_size += new_size >> 2;
188 state->buf_offset = 0;
190 state->buf_clear = 0;
191 state->buf_total = 0;
192 state->stack_top = 0;
205 state->memory = source->memory;
207 state->prefix =
NULL;
208 state->suffix =
NULL;
209 state->prefix_size = 0;
211 state->stack = state->stack_0;
212 state->stack_size =
sizeof ( state->stack_0 );
226 if ( state->stack != state->stack_0 )
230 state->suffix =
NULL;
236 #define FTLZW_STACK_PUSH( c ) \ 238 if ( state->stack_top >= state->stack_size && \ 239 ft_lzwstate_stack_grow( state ) < 0 ) \ 242 state->stack[state->stack_top++] = (FT_Byte)(c); \ 253 FT_UInt old_char = state->old_char;
254 FT_UInt old_code = state->old_code;
255 FT_UInt in_code = state->in_code;
261 switch ( state->phase )
276 state->max_free = (
FT_UInt)( ( 1UL << state->max_bits ) - 256 );
282 state->free_ent = ( state->block_mode ?
LZW_FIRST 286 state->free_bits = state->num_bits < state->max_bits
287 ? (
FT_UInt)( ( 1UL << state->num_bits ) - 256 )
288 : state->max_free + 1;
290 c = ft_lzwstate_get_code( state );
294 old_code = old_char = (
FT_UInt)c;
299 if ( ++result >= out_size )
313 c = ft_lzwstate_get_code( state );
319 if ( code ==
LZW_CLEAR && state->block_mode )
322 state->free_ent = (
LZW_FIRST - 1 ) - 256;
323 state->buf_clear = 1;
337 if ( code - 256U >= state->free_ent )
340 if ( code - 256U > state->free_ent )
347 while ( code >= 256U )
349 if ( !state->prefix )
353 code = state->prefix[code - 256];
366 while ( state->stack_top > 0 )
371 buffer[
result] = state->stack[state->stack_top];
373 if ( ++result == out_size )
378 if ( state->free_ent < state->max_free )
380 if ( state->free_ent >= state->prefix_size &&
381 ft_lzwstate_prefix_grow( state ) < 0 )
384 FT_ASSERT( state->free_ent < state->prefix_size );
386 state->prefix[state->free_ent] = (
FT_UShort)old_code;
387 state->suffix[state->free_ent] = (
FT_Byte) old_char;
389 state->free_ent += 1;
403 state->old_code = old_code;
404 state->old_char = old_char;
405 state->in_code = in_code;
FT_Stream_Seek(FT_Stream stream, FT_ULong pos)
#define NextCode(_tif, _sp, _bp, _code, _get)
FT_Stream_TryRead(FT_Stream stream, FT_Byte *buffer, FT_ULong count)
GLsizei GLsizei GLchar * source
ft_lzwstate_reset(FT_LzwState state)
#define FTLZW_STACK_PUSH(c)
#define FT_ASSERT(condition)
FT_Byte stack_0[FT_LZW_DEFAULT_STACK_SIZE]
#define FT_RENEW_ARRAY(ptr, curcnt, newcnt)
ft_lzwstate_done(FT_LzwState state)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
ft_lzwstate_init(FT_LzwState state, FT_Stream source)
GLuint GLuint GLsizei count
#define FT_REALLOC_MULT(ptr, oldcnt, newcnt, itmsz)
#define FT_MEM_MOVE(dest, source, count)
ft_lzwstate_io(FT_LzwState state, FT_Byte *buffer, FT_ULong out_size)