Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Bitstream decoding
2015-07-20 09:34
lft

Registered: Jul 2007
Posts: 369
Bitstream decoding

I wrote a little article about fast bitstream decoding over at codebase. Enjoy!
 
... 3 posts hidden. Click here to view all posts....
 
2015-07-20 12:57
TNT
Account closed

Registered: Oct 2004
Posts: 189
One more trick mentioned here: you get free OR operation by loading A with a value with multible bits set :)
2015-07-20 13:00
Flavioweb

Registered: Nov 2011
Posts: 447
Nice! Thanks a lot!
2015-07-20 18:01
Bitbreaker

Registered: Oct 2002
Posts: 500
The routine is nice, but gets unhandy when the number of bits to be fetched is determinded while fetching, consider for e.g. the elias gamma encoding as being used to encode the lengtths in doynax/byteboozer?
One would need to shift in from the right side ones for building up a counter and then shift them out again to the left when fetching the bits to be fetched for a number. So one would need at least the ability to change the direction of the shifter.
I counted some cycles and it is just as fast as a jsr to get_byte in case, but of course it reduces code. But there's overhead after each fetch with the table lookup. Also when using x as lowbyte and index, things can be made faster:

ldy buffer,x
inx
bne no_new_page

Of course x then can't be used anywhere else.
2015-07-20 18:56
lft

Registered: Jul 2007
Posts: 369
Quoting Bitbreaker
consider for e.g. the elias gamma encoding as being used to encode the lengtths in doynax/byteboozer?


Yes, for some applications, there is no need for generic decision trees. Then it might be faster to use other methods. My approach can in principle be used to encode Elias Gamma or Huffman (with 128 symbols, I think), because both of these can be regarded as decision trees. But certainly, for the Elias Gamma case, it should be faster to use right-shifting instead of having a table entry for each shift position. And for Huffman, there is no need to support fields wider than one bit, so that can probably also be optimised.

Quote:
Also when using x as lowbyte and index, things can be made faster:

ldy buffer,x
inx
bne no_new_page

Of course x then can't be used anywhere else.


This is an excellent improvement. Why didn't I think of that? =)
2015-07-20 21:54
lft

Registered: Jul 2007
Posts: 369
Quoting lft
This is an excellent improvement. Why didn't I think of that? =)


Oh, now I remember. I did think of it. In the final decoder, both A and Y need to be preserved. Therefore, if we use indexed addressing to save four cycles, we must also save and restore one of those registers, at a cost of six cycles.
2015-07-21 18:09
Frantic

Registered: Mar 2003
Posts: 1627
Dear Sir lft,

Thank you for your most excellent addition to the codebase.

My very best wishes,
Frantic
2015-07-22 19:13
Glasnost
Account closed

Registered: Aug 2011
Posts: 26
Nice article :)

Another good example of code optimisation.

replace the ..
clc
jmp decodeloop

with
clc
bcc decodeloop

and save a byte.
2015-07-22 20:40
Peiselulli

Registered: Oct 2006
Posts: 81
... and add a cycle if a page is crossed ;-(
2015-07-23 04:31
Mr. SID

Registered: Jan 2003
Posts: 421
Don't cross the pages!
2015-07-23 07:30
Oswald

Registered: Apr 2002
Posts: 5017
Previous - 1 | 2 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
A3/AFL
Didi/Laxity
apprentix
Krill/Plush
Ray Manta/DataDoor
Acidchild/Padua
Mythus/Delysid
Guests online: 138
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Bromance  (9.6)
10 Memento Mori  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Original Suppliers
1 Derbyshire Ram  (9.5)
2 Black Beard  (9.4)
3 hedning  (9.2)
4 Baracuda  (9.1)
5 Irata  (8.5)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.044 sec.