--- srle-0.1.c 2007-01-03 11:47:13.000000000 +0100 +++ srle-0.2.c 2007-01-03 12:08:49.000000000 +0100 @@ -20,12 +20,17 @@ * * Compressed (encoded) format: * - * FILE = ( TIME DATA )* + * FILE = ( CNT-1 DATA )* * - * TIME = nTime bytes, MSB first + * CNT = nTime bytes, MSB first * * DATA = nData bytes * + * Changelog: + * + * 0.2 ... time is encoded from 0 (= count 1) + * which allows to use the full scale + * */ /* libraries */ @@ -52,7 +57,7 @@ if ((c=fgetc(stream))==EOF) return 0; o = (o << 8) + c; } - *time = o; + *time = o+1; return 1; } @@ -72,6 +77,7 @@ /* output routines */ void write_time( FILE *stream, int i ) { int n = nTime; + --i; while(n--) { fputc( (i >> (8*(nTime-1))) & 0xFF, stream ); i = i << 8; @@ -98,7 +104,7 @@ int srle_encode( FILE *in, FILE *out ) { int time = 0; - int max = (1<<(8*nTime))-1; + int max = 1<<(8*nTime); unsigned char *data; unsigned char *buff;