Nice optimization bitRAKE, I need the lower word P in table A also for checking if a code is valid, so I think it will be:
I tried this code and I was able to decode a huffman stream that used a fixed huffman table. I wrote an algorithm for creating table A and B, based on the code length for each symbol.
Thomas
mov dx, [ebx]
; get code in eax and check if correct using dx
; then lookup:
neg ax
add ax, dx
add ax, [ebx + 2]
mov edx, [ebx + 2 * eax]
; or slightly different:
sub dx, ax
add dx, [ebx + 2]
mov edx, [ebx + 2 * edx]
(assuming the high word of edx is zero)
I tried this code and I was able to decode a huffman stream that used a fixed huffman table. I wrote an algorithm for creating table A and B, based on the code length for each symbol.
Thomas
mov dx, [ebx]
; get code in eax and check if correct using dx
; then lookup:
sub ax, [ebx + 2]
mov edx, [ebx + 2 * eax + Const]
(assuming the high word of eax is 0FFFFh)
This should be possible with slight modification of the table. I will work more on this over the weekend - not any time to spare right now. :)
Const = size of second table.
= old( + + (following codes))
I'm mightly impressed!
You guys are onto what is known as "canonical Huffman coding". With no trees in the decode you eliminate all that pointer chasing and everything is down to a very cachable scan of your bit length starting entries & you calc the address of the uncode in one fell swoop.
Did you finish it off into a lib or DLL? No biggie if not, but I'm playing with writing a Burrows/Wheeler zip proggie that it might fit into.
big time:alright:
You guys are onto what is known as "canonical Huffman coding". With no trees in the decode you eliminate all that pointer chasing and everything is down to a very cachable scan of your bit length starting entries & you calc the address of the uncode in one fell swoop.
Did you finish it off into a lib or DLL? No biggie if not, but I'm playing with writing a Burrows/Wheeler zip proggie that it might fit into.
big time:alright:
Yeah, Thomas whipped up a great library!
PNGlib, go get it at his website.
PNGlib, go get it at his website.
Thanks! It looks like there may be a lot more than I really need for my purposes. If I actually get off my lazy ass & translate my lame-o c snippetts to assembly I'll post the results, fully crediting all those I stole from of course.
How's that quote go? "Fat dumb & lazy is no way to go thru life son." Maybe I should have listened.
How's that quote go? "Fat dumb & lazy is no way to go thru life son." Maybe I should have listened.