home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 2 / LSD and 17bit Compendium Deluxe - Volume II.iso / a / prog / cprog / ddjcomp.lha / urban / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-30  |  976 b   |  59 lines

  1. /* bitwise statistical compression */
  2. #include <stdio.h>
  3. #include "head.h"
  4. #include "var.h"
  5. #include "init.c"
  6. #include "hash.c"
  7. #include "setpoint.c"
  8. #include "send.c"
  9. #include "sendbits.c"
  10. #include "sendbit.c"
  11. #include "shift.c"
  12. #include "backhash.c"
  13. #include "flush.c"
  14. #ifdef UN
  15. #include "getbit.c"
  16. #endif
  17.  
  18. main() {
  19.   int c;
  20.   unsigned char t0;
  21.   init();
  22. #ifdef UN
  23.   while (apoint!=low) {
  24. #else
  25.   while (EOF!=(c=getchar())) {
  26. #endif
  27.     ++low; /* send no EOF */
  28.     t[at]=t0=0x80;
  29.     while (t0) {
  30.       set_point();
  31. #ifdef UN
  32.       if(apoint>point){c=t0;}
  33.       else {c=0;}
  34.       sendb(c);
  35. #else
  36.       sendb(c&t0);
  37. #endif
  38.       hk=(HKSIZE+hk-t[at])%HKSIZE;
  39.       hv=(HVSIZE+hv-t[at])%HVSIZE;
  40. #ifdef UN
  41.       if (c==0) t[at]^=t0;
  42.       t0>>=1;
  43.       t[at]|=t0;
  44. #else
  45.       t0>>=1;
  46.       t[at]=(t[at]&c)|t0;
  47. #endif
  48.     }
  49.     hk+=t[at];
  50.     hv+=t[at];
  51.     hash();
  52.     at=(1+at)%TSIZE;
  53.     if(at==to) backhash();
  54.   }
  55.   high=low; /* send EOF */
  56.   send_bits();
  57.   flush_bits();
  58. }
  59.