home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / graphics / gifbla20.zip / SOURCE / ARITH.H < prev    next >
C/C++ Source or Header  |  1992-12-15  |  2KB  |  48 lines

  1.  
  2. /* arith.h - Include file for arithmetic coding routines. */
  3.  
  4. #ifndef P_DEFINED
  5. #define P_DEFINED
  6. #ifdef NOPROTOS
  7. #define P(a,b) b
  8. #else
  9. #define P(a,b) a
  10. #endif
  11. #endif
  12.  
  13. typedef struct {
  14.     FFILE *ff;
  15.     long low,high;
  16.     union {
  17.         struct {
  18.             long bits_to_follow;
  19.         } e;
  20.         struct {
  21.             long value;
  22.         } d;
  23.     } u;
  24. } ARITH_CODER;
  25.  
  26. extern int arith_start_encoding P((ARITH_CODER *ac, FFILE *ff),());
  27. /* Prepares to do arithmetic encoding to ff. Returns 0 on success,
  28.     or -1 on failure. */
  29. extern int arith_encode P((ARITH_CODER *ac, int rstart, int rend, int rtot),());
  30. /* Encodes a fraction rstart..rend of the interval 0..rtot-1. Returns 0
  31.     on success, or -1 on failure. */
  32. extern int arith_end_encoding P((ARITH_CODER *ac),());
  33. /* Ends encoding. Returns 0 on success, or -1 on failure. */
  34. extern int arith_start_decoding P((ARITH_CODER *ac, FFILE *ff),());
  35. /* Prepares to do arithmetic decoding from ff. Returns 0 on success,
  36.     or -1 on failure. */
  37. extern int arith_decode_getrpos P((ARITH_CODER *ac, int rtot),());
  38. /* Gets the decoder's current position within 0..rtot-1. */
  39. extern int arith_decode_advance P((ARITH_CODER *ac,
  40.     int rstart, int rend, int rtot),());
  41. /* Advances the decoder to account for a fraction rstart..rend of the
  42.     interval 0..rtot-1. If rpos was the position returned by
  43.     arith_decode_advance, then rstart..rend should be the interval
  44.     within the appropriate context such that rstart<=rpos<rend.
  45.     Returns 0 on success, or -1 on failure. */
  46. extern int arith_end_decoding P((ARITH_CODER *ac),());
  47. /* Ends decoding. Returns 0 on success, or -1 on failure. */
  48.