I just had an idea for an even simpler RLE compression algorithm. I got the idea from the old .PCX RLE system, which were good for compressing 1bit data (b/w images) doing one funcion for each data byte. ENCODING: * if bitstream data has no long strings just save 7 bits: First bit is a flag that shows data is 7 separate bits (x=0). incoming: 111010110110 stored: x1110101 * if bitstream is for this byte is all "1"s or "0"s, this is a run, so tally the total length from here until the run ends. Then express the remainder of the run as a 7bit length. First bit flag is (x=1) showing the other 7 bits are a run-length code. incoming: 111111111111 -> continues to 41 places stored: x010 1001 (binary for length=41) The bit type, a "1" or "0" is determined from the last bit of the previous byte, so it will compress runs from 9 onwards, depending on where the run crosses the byte boundary. This compression system is VERY simple to encode or decode, one simple calc per 8 bits. A PIC could definitely encode high quality audio bitstream in real time. -Roman Roman Black wrote: > Hi, are you talking an ENCODING delay? > Encoding just generates the bitstream using the > RC filter model vs the desired analogue waveform, > then the encoder does the simple RLE compression > system in one pass. No encoding problems. > Depending on the simplicity of your RC filter > model you might even get an encoder on a PIC, > it only requires one calc per incoming "bit" > sample. > > DECODING is by one bit per PIC interrupt > (for instance) and if the PIC gets 5 consecutive > "1" or "0" bits, it sets a specified period > based on the value of the next 8 bits, giving > ACCURATE periods from 5 to 260 bits. > Since the bitstream data is loaded as bytes > you only need the current byte you are decoding > bits from and the next byte already loaded. > I suppose that is a lookahead buffer but > a very easy one. That way you always have the > "next" 8 bits handy if you detect a compression > command. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu