Solved

data compression on the fly

Posted on 2001-06-11
9
218 Views
Last Modified: 2010-04-02
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
Comment
Question by:boyracer
9 Comments
 
LVL 32

Expert Comment

by:jhance
Comment Utility
Why do you want to bother with compression if, as you say, "resulting size is not so important"??
0
 

Author Comment

by:boyracer
Comment Utility
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
 
LVL 2

Expert Comment

by:missionImpossible
Comment Utility
0
 

Author Comment

by:boyracer
Comment Utility
the codeguru stuff works for files, but I assume
I can take parts of the code ...
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 2

Expert Comment

by:joe_h
Comment Utility
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
 
LVL 7

Expert Comment

by:KangaRoo
Comment Utility
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
 

Author Comment

by:boyracer
Comment Utility
hey joe...
it is going to be ascii
0
 
LVL 2

Accepted Solution

by:
joe_h earned 50 total points
Comment Utility
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
 

Author Comment

by:boyracer
Comment Utility
thanks for your comments
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now