Xref: utzoo comp.graphics:17157 comp.compression:301 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!mips!daver!dlb!netcom!marcos From: marcos@netcom.COM (Marcos H. Woehrmann) Newsgroups: comp.graphics,comp.compression Subject: Re: gif encoding questions Message-ID: <1991Apr10.034324.28971@netcom.COM> Date: 10 Apr 91 03:43:24 GMT References: <1991Apr9.142255.186@unhd.unh.edu> Followup-To: comp.compression Organization: Netcom - Online Communication Services UNIX System {408 241-9760 guest} Lines: 55 In article <1991Apr9.142255.186@unhd.unh.edu>, rg@msel.unh.edu (Roger Gonzalez) writes: > > When encoding in GIF format, do you increase the bitsize when you > _output_ code c, or when you _add_ an entry to the c-th entry in the > string table? > > What about when c = 4095? Do you output the clear code and reinitialize > after 4095 is output, or after the 4095th entry in the table is used? if (hashLocation>maxHashTable) panic("Internal error while writing Gif (1)\n"); if (lastUsed==maxUsable) { if (codeSize==maxBits) { /* can't increase bit size, clear table! */ resetTable(clearCode,out); return; } else { codeSize++; maxUsable=1 << codeSize; } } However, according to the GIF89A spec (availble from CompuServe and from Simtel): "There is not a requirement to send a clear code when the string table is full". (And they go on to say you could actually clear the table before it is full, though how you decide the optimal time to do that is left as an exercise to the interested reader :-) ). As an aside does anyone know if any of the GIF writers make use of this yet? The document I have points out that most (all?) gif readers will break unless you only issue a clear code when the table is full, and suggests that gif writers don't implement a early or late clear code until after Jan. 1991, by which time all the gif readers will have been fixed. > > Why have I seen gray scale (256) GIFs that don't have simple color maps like > 00 00 00 01 01 01 02 02 02 03 03 03 ... FE FE FE FF FF FF > > The GIF spec suggests that you sort the Global Color Table (aka palette) by order of importance (which most people of interpreted to mean in order of frequency). "This assists a decoder, with fewer available colors, in choosing the best subset of colors..." marcos -- Marcos H. Woehrmann {claris|apple}!netcom!marcos | marcos@netcom.COM Oh, I'm sure you've heard it all before, but remember it's not what you say, it's how you say it, and how much you're paid to do so, and besides who's listening anyway. No one, that's who, because it's all been said and done and done and done and done to death. Let's talk about art, said the fool to the idiot. --Lydia Lunch