AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2003.03.26 12:02 "LZW and 4bit tiffs", by John Carter
2003.03.26 23:30 "Re: LZW and 4bit tiffs", by Michael Still
2003.03.27 16:38 "RE: LZW and 4bit tiffs", by John Carter

2003.03.26 12:02 "LZW and 4bit tiffs", by John Carter

Hi

I'm having great fun here trying to write a LZW decompression function.

I've pretty much stuck to the description given in section 13 of the tiff spec (v6)

it goes more or less like so

  1. read in a compressed strip
  2. extract codes until EOI (257 dec) (keeping track of bit boundaries etc)

the codes I'm getting out seem ok

I have 2 questions

  1. should the code you extract be in the table or at least
  2. if not in the table the index to where the next new string will be added,
  3. if statement 1 is false should the new string be written to location table[code]
  4. or should it be written to the first available free space in the table.

the reason i ask is that with the following sequence of code extractions and table additions i end up adding two strings of length 0 together ( malloc complains about this ).

thanks jc

code        result
256          init table
153
258
259
260
261
262
87
173
203
247
251
268
269
270
383 ?
253           both strings = 0 length
265
272
275
240
274
276
113
265
274
280
276
250
283
277
399 ?
286           both strings = 0 length
271
277
289
269
111
257           EOI code

____________________________

John Carter
BSS O&M Development group,
Motorola,
Mahon Industrial Estate,
Cork.