POV-Ray : Newsgroups : povray.binaries.scene-files : Most convoluted scene of its kind? : Re: Most convoluted scene of its kind? Server Time
1 Sep 2024 18:16:54 EDT (-0400)
  Re: Most convoluted scene of its kind?  
From: Andrew the Orchid
Date: 31 Oct 2004 11:28:13
Message: <4185129d@news.povray.org>
> From looking at the code, I'll guess it reads the strings
> with a hex-coded file (sort of like uuencode, binhex, or
> mime) in them.  This is output as a "pseudo binary" file,
> with each one or zero being written as asn ascii zero or
> ascii one, separated by commas.  This is turn is read
> back in and read through what looks like a fixed huffman
> tree decompressor[1] which yeilds a file containing the
> actual povray scene file.

Yups, that is indeed *exactly* what it does.

(Would have used canonical Huffman rather than explicitly storing the 
codebook - but the code to recompute the codebook is larger than the 
codebook itself, so...)

It's not uuencode or BASE-64 or anything... just plain vanila hexdecimal 
8-D Would probably take up less space if I changed it to BASE-64... (Uh, 
I mean, it would *definitely* take up less space... but not sure about 
the decode part!)

> Now I'm going to render it and see.  :)

Heh. Hope you have a fast PC...

Seriously... the hex -> binary decode is almost instant. The Huffman 
decompression takes ~30 seconds or so. And the image itself takes 
*forever*...

> Most impressive coding, regardless of what the final
> scene ends up being.  Stuff like this makes me
> wish pov-ray had actual "real" binary file I/O.

Why thank you.

I'm actually impressed that I can get POV-Ray to dump raw binary. (I 
presume you noticed that I only bothered having encodings for 7-bit 
ASCII?) I could get #write() to produce arbitrary binary, actually... 
Like you say, a pitty that #read() can't pick up a character at a time...

(If it could, those WriteBinary() macros would vanish. Just #write() the 
hex to a file, then read it back and convert to binary in another file - 
then read *that* back like it currently does. Would be nice to dispence 
with the commas also...)

I actually tried to write a version that uses arithmatic coding. In 
fact, it works. Expect... Sometimes - just sometimes - the decoder 
utterly looses synchronisation with the encoder, and I can't figure out 
why. :'(

So there we have it - a 4KB file that produces a 1KB file and renders 
it. Worth it? Nah. Fun? Well, you decide. ;-)

Andrew.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.