SE Does Not Like Dissent
SE Does Not Like Dissent

Reputation: 1825

GIF Data Storage specification question

In the GIF specification, here:

http://www.w3.org/Graphics/GIF/spec-gif89a.txt

I am having trouble understanding two parts of it:

It specifies for 'LZW minimum code size' that:

This byte determines the initial number of bits used for LZW codes in the image data, as described in Appendix F.

  1. What does it mean 'initial number of bits used for LZW codes'?
  2. How do LZW codes work in the context of GIFs? (I understand it refers to Lempel-Ziv-Welch).
  3. Where is the elusive 'appexdix F' it refers to? (It isn't in the body).

It also specifies that after the single byte for the 'LZW minimum code size', there is a block called 'Image Data', of which the actual size is unspecified, and is just called 'Data Sub-blocks'.

Sorry for all the questions. Thank you for your time.

As a side-note: Even a partial answer or an answer to any of the questions would be greatly appreciated.

Upvotes: 2

Views: 480

Answers (1)

undur_gongor
undur_gongor

Reputation: 15954

  1. GIF applies the LZW algorithm with a variable (increasing) size of codes as described in Wikipedia LZW. The 'initial number of bits' is the initial size of the codes.

  2. This is described in the document you refer to. The list of color codes of the pixels is LZW compressed (paragraph "a" just above the part you are citing).

  3. It is there in the file (on page 30 ;-) near the end, just search for "Variable-Length-Code LZW Compression")

  4. The "data sub-blocks" are the actual image data in chunks of 255 (or less bytes). Maybe the

The linked lists used by the image data and the extension blocks consist of series of sub-blocks, each sub-block beginning with a byte giving the number of subsequent data bytes in the sub-block (1 to 255), the series terminated by the empty sub-block (a 0 byte). [Wikipedia GIF]

  1. "How do I work out the size of the data sub-blocks?" See above. It is the first byte of each of the blocks.

  2. See above.

Upvotes: 2

Related Questions