The Godfather talking
Share your stuff or I will make you regret it.
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 10, 2016, 05:24:08 17:24


Login with username, password and session length


Pages: [1]
Print
Author Topic: How to compress constant data table  (Read 1820 times)
0 Members and 1 Guest are viewing this topic.
localcrack
Active Member
***
Offline Offline

Posts: 171

Thank You
-Given: 62
-Receive: 20



« on: May 27, 2013, 04:37:30 16:37 »

I am developing a one program in keil for Atmel chip AT89C2051. In this program I use constant data table to store constant value in ROM. My base code that will handles one 7 Segment display two switches for up and down and some port handling operation with constant data that will requires around 1 Kb of space. Now my question is that the constant data table space which I needs for this program will also increased to around 2.5 Kb so it will out of space for selected chip. I checked that my data table has lots of repetitive value (around 80% repetitive value) so I needs some technique to compress this data table to fit it on my selected chip. Please note that I do not want to change chip to increase the code space.

Keil supports RW data compression but I think this will works on only ARM controllers. Please see the link for more info.

http://www.keil.com/support/man/docs/armlink/armlink_chddibfi.htm
Logged
titi
Active Member
***
Offline Offline

Posts: 192

Thank You
-Given: 1435
-Receive: 705



« Reply #1 on: May 27, 2013, 08:46:39 20:46 »

Hi localcrack,

a simple way to compress data is the RLE (Run length encoding) algorithm.

Do a search with google for RLE it was used by PCX image format and some BMP.

Best regards.
Logged
Magnox
V.I.P
Active Member
*****
Offline Offline

Posts: 208

Thank You
-Given: 775
-Receive: 238


Oink!


« Reply #2 on: May 27, 2013, 09:26:41 21:26 »

Hmm... RLE is probably the only standard compression method that can be considered really, given the code space limitations. The trick will be making the code smaller than the saving in data.

What format is the data? Is it any value in an 8-bit range, for instance, or only 4 bits, 6 bits, or only certain values within a larger range (like only 2,4,6,8 etc, or whatever)?

There might be other ways to compact the data, or a way to implement a modified form of RLE.

Is it possible to calculate any parts of the data, or is it not related simply to any input?

Another trade of will be speed of course. The more complex the algorithm, the slower your code will run.
Logged
localcrack
Active Member
***
Offline Offline

Posts: 171

Thank You
-Given: 62
-Receive: 20



« Reply #3 on: May 28, 2013, 01:55:00 13:55 »

I tried RLE but compression ratio is very low because repeated bytes are not in sequence. Sometimes this algorithm adds two bytes instead of two. I checked my data that there are lot's of similar two byte togather eg. AA BB CC and there are few three bytes together eg. AAA BBB CCC and there are lot's of single repeated bytes between similar byte's pair eg. AA D BB D CC D FF D etc.

If I compress this types of data with RLE then compression ratio is very low or sometimes no compression is possible.

For example,

Uncompressed : AAA D BB C BB FFF E CC = 15 Bytes
Compressed :    3A 1D  2B 1C 2B 3F 1E 2C = 16 Bytes
                           ^        ^          ^
                       Here this algorithm adds two byte instead of one

Uncompressed : AAA D BB C BB FFF E CC = 15 Bytes
Compressed :    3A 1D  2B 1C 2B 3F 1E 2C = 16 Bytes
                       ^                    ^
                      Compression done reduced one byte

Uncompressed : AAA D BB C BB FFF E CC = 15 Bytes
Compressed :    3A 1D  2B 1C 2B 3F 1E 2C = 16 Bytes
                                ^                   ^
                      Compression not possible original and compressed byte count are same.
Logged
Ichan
Hero Member
*****
Offline Offline

Posts: 840

Thank You
-Given: 312
-Receive: 387



WWW
« Reply #4 on: May 28, 2013, 09:05:24 21:05 »

Curious i am, googling found Heatsrhink with codes available on GitHub.

No time yet to play with it, let us know if you do..

-ichan
Logged

There is Gray, not only Black or White.
bigtoy
Active Member
***
Offline Offline

Posts: 153

Thank You
-Given: 132
-Receive: 197


« Reply #5 on: June 02, 2013, 03:23:28 03:23 »

Heatshrink - nice find. Looks quite interesting for all kinds of things.
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC