• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

data compression on the fly

I have checked the search engines but did not find
a good answer

what I have is a

char buf[1024]

and would like to have it compressed as fast
as possible , resulting size is not so important.
hopefully less...

is there any API which compresses / decompresses
this user data ?
0
boyracer
Asked:
boyracer
1 Solution
 
jhanceCommented:
Why do you want to bother with compression if, as you say, "resulting size is not so important"??
0
 
boyracerAuthor Commented:
well, if the compression rate is 40-50%, it is still good.

I do not need 80% or higher.

with less bytes, I could overcome some hardware limitations
0
 
missionImpossibleCommented:
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
boyracerAuthor Commented:
the codeguru stuff works for files, but I assume
I can take parts of the code ...
0
 
joe_hCommented:
It would be helpful to specify what kind of data do you store in that buffer (mostly zeroes? ASCII strings? digits? sound samples?). Otherwise, I'd say it is very hard to give you a generic algoritm that would do even the 40%...
Joe_h
0
 
KangaRooCommented:
LZW compression is well suited to compress data streams (you could chain compressor and decompressor, it doesn't need to read an entire file) /very/ /fast/

It is a string->code compression, but it is mostly suitable only for data which contains repetive strings, like text or images.

And it is patented :(

For a wider choice of data-compression resources try http://www.dogma.net/DataCompression/
0
 
boyracerAuthor Commented:
hey joe...
it is going to be ascii
0
 
joe_hCommented:
All right boyracer... Assuming "standard" ASCII set, that is character codes 0 to 127, you need only 7 bits to encode one char. Therefore, you can achieve 12,5% compression just by stripping the 8th bit from each char and packing them together to fill up the "holes".

If you limit yourself to, let's say, uppercase letters, numbers 0-9, and up to 28 special symbols (for a total of 64 different codes - however, they'll no longer be ASCII), you need only 6 bits, allowing for 25% compression.

Does this sound good enough?
0
 
boyracerAuthor Commented:
thanks for your comments
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now