THIS code is of SMurf & corrected by swoopy
plzzz can some one give me whole program means its main function & also comments on each line which help me in understanding this prog as i cant understand
why
mask1 = 0x7F;
mask2 = 0x40;
rshift = 6;
this take & while (src - in < 17280)this also why only 17280?
& also not understand some function also so plzzzzzz help me in this regard & plzz give me main function with comments if u can
thanks in advance.
its urgent plzz.
Hello,
I'm trying to write two small functions that compresses/decompresses 7-bit data that is packed together into 8 bits. These are my alogrithms:-
insert
Code:
Code:
int compress(unsigned char *in, unsigned char *out)
{
unsigned char *src, *dest, mask1, mask2;
int lshift, rshift;
src = in;
dest = out;
while (src - in < 17280) //size of imput data
{
mask1 = 0x7F;
mask2 = 0x40;
rshift = 6;
for (lshift=1;lshift<8;lshift++)
{
*dest = ( (*(src++) & mask1) << lshift);
*dest++ |= ((*src & mask2) >> rshift--);
mask1 >>= 1;
mask2 |= (mask2 >> 1);
}
src++;
}
return 0;
}
int decompress(unsigned char *in, unsigned char *out)
{
unsigned char *src, *dest, mask1, mask2;
int lshift, rshift;
src = in;
dest = out;
while (src - in < 17280) //size of imput data
{
mask1 = 0x00;
mask2 = 0xFE;
rshift = 1;
for (lshift=7;lshift>=0;lshift--)
{
if (lshift == 7)
*dest++ |= ((*src & mask2) >> rshift++);
else
{
*dest = ((*(src++) & mask1) << lshift);
*dest++ |= ((*src & mask2) >> rshift++);
}
mask1 <<= 1;
mask1++;
mask2 <<= 1;
}
}
return 0;
}