inc/rle.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int rleCompress (void *in, int inSize, signed char *out)
void rleUncompress (signed char *in, int inSize, void *out, int outSize)


Function Documentation

int rleCompress ( void *  in,
int  inSize,
signed char *  out 
)

Definition at line 24 of file rle.c.

References countSameAsStart().

00027 {
00028 signed char *in = vIn;
00029 signed char *endIn = in + inSize;
00030 signed char *s = in, *d = out;
00031 signed char *uncStart = in;
00032 int uncSize, sameCount;
00033 int sizeLeft;
00034 
00035 while ((sizeLeft = (endIn - s)) != 0)
00036     {
00037     sameCount = countSameAsStart(s, sizeLeft);
00038     uncSize = s - uncStart;
00039     if (sameCount >= 3)
00040         {
00041         int uncSize = s - uncStart;
00042         while (uncSize > 0)
00043             {
00044             int size = uncSize;
00045             if (size > 127) size = 127;
00046             *d++ = size;
00047             memcpy(d, uncStart, size);
00048             d += size;
00049             uncSize -= size;
00050             uncStart += size;
00051             }
00052         *d++ = -sameCount;
00053         *d++ = *s;
00054         s += sameCount;
00055         uncStart = s;
00056         }
00057     else
00058         s += sameCount;
00059     }  
00060 uncSize = s - uncStart;
00061 while (uncSize > 0)
00062     {
00063     int size = uncSize;
00064     if (size > 127) size = 127;
00065     *d++ = size;
00066     memcpy(d, uncStart, size);
00067     d += size;
00068     uncSize -= size;
00069     uncStart += size;
00070     }
00071 return d - out;
00072 }

Here is the call graph for this function:

void rleUncompress ( signed char *  in,
int  inSize,
void *  out,
int  outSize 
)

Definition at line 74 of file rle.c.

00076 {
00077 int count;
00078 signed char *out = vOut;
00079 signed char *endOut = out + outSize;
00080 #ifndef NDEBUG
00081 signed char *endIn = in + inSize;
00082 #endif
00083 
00084 while (out < endOut)
00085      {
00086      count = *in++;
00087      if (count > 0)
00088           {
00089           memcpy(out, in, count);
00090           in += count;
00091           out += count;
00092           }
00093     else
00094           {
00095           count = -count;
00096           memset(out, *in++, count);
00097           out += count;
00098           }
00099           
00100     }
00101 assert(out == endOut && in == endIn);
00102 }


Generated on Tue Dec 25 19:14:13 2007 for blat by  doxygen 1.5.2