EmbLogic's Blog

MULTIPLE DATA COMPRESSION

Multiple Data compresion is technique to compress more than 50 percent of the data,by using iteration methods in C language.

before compession and decompession there are certain function we have to perform;-

MASTER ARRAY

Array is the collection of elements of same data type in continous memory location.here,we create the array of all the characters including space and put them in array which is called as master array.from where we call all the repeated character of main string from there index.

CODELENGTH

Codelength is the no.of bits in which we have to keep the data i.e. a character takes 1 byte and integer take 4 byte for its storage but an integer can represent in 4 bits or 3 bits in how many bits we have to represent data  it is decided by code length .

COMPRESSION

logically in compression ,we compress the data i.e. firstly we put all the data in array as described earlier simultaneously we create index and after making index we call the characters through their index .By using bitwise shift operator we shift the index value  and put it into a character (type casting) using bitwise OR (|) the 2 byte data stored in 1 byte.here 50% compression is done.

ch=ch<<4;
ch2=ch|ch1;

DECOMPRESSION

In decompression ,logically we repeat the reverse process of compression

STEPS TO COMPRESS AND DECOMPRESS.

COMPRESSION
1.) Open the file to be compressed.
2.) Find the distinct characters in the file and store it in an array(master array).
3.) From the master array find the maximum number of bits required to represent each distinct character in compressed file.
4.) Read the file character by character.
5.) Replace each character with the index of the corresponding character in master array.
6.) Manipulate the indexes in the form of 1 byte using shift operations.
7.) Write the manipulated indexes to the compressed file.
8.) Store the master array in other file so that it could be used at the time of decompression.

DECOMPRESSION
1.) Open the compressed file.
2.) Open the file containing master array and store it in array.
3.) Form the master array find out the number of bits used to represent each character.
4.) Read the compressed file character by character.
5.) From this read characters filter out the actual ASCII characters using shift operations and indexes.
6.) Save the filtered out ASCII characters to new file.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>