boolhuff.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /****************************************************************************
  2. *
  3. * Module Title : boolhuff.H
  4. *
  5. * Description : Video CODEC
  6. *
  7. * AUTHOR : James Bankoski
  8. *
  9. *****************************************************************************
  10. * Revision History
  11. *
  12. * 1.00 JBB 01JUN01 Configuration baseline
  13. *
  14. *****************************************************************************
  15. */
  16. /****************************************************************************
  17. * Header Files
  18. *****************************************************************************
  19. */
  20. #ifndef boolhuff_h
  21. #define boolhuff_h
  22. #ifdef NOTNORMALIZED
  23. typedef struct _boolcoder
  24. {
  25. unsigned char *buffer;
  26. unsigned int pos;
  27. union
  28. {
  29. unsigned int value;
  30. unsigned char v[4];
  31. };
  32. unsigned int range;
  33. } BOOL_CODER;
  34. #else
  35. typedef struct
  36. {
  37. unsigned int bits;
  38. unsigned int bitpos;
  39. unsigned int *source;
  40. unsigned int pos;
  41. } bitpump;
  42. typedef struct
  43. {
  44. unsigned int lowvalue;
  45. unsigned int range;
  46. unsigned int value;
  47. int count;
  48. unsigned int pos;
  49. unsigned char *buffer;
  50. // Variables used to track bit costs without outputing to the bitstream
  51. unsigned int MeasureCost;
  52. unsigned long BitCounter;
  53. } BOOL_CODER;
  54. #endif
  55. extern void StartDecode(BOOL_CODER *bc, unsigned char *buffer);
  56. extern int DecodeBool(BOOL_CODER *bc, int context);
  57. extern int DecodeBool128(BOOL_CODER *bc);
  58. extern void StopDecode(BOOL_CODER *bc);
  59. extern void StartEncode(BOOL_CODER *bc, unsigned char *buffer);
  60. extern void EncodeBool(BOOL_CODER *bc, int x, int context);
  61. extern void EncodeBool2(BOOL_CODER *bc, int x, int context);
  62. extern void StopEncode(BOOL_CODER *bc);
  63. extern double shannonCost0[256];
  64. extern double shannonCost1[256];
  65. extern unsigned int shannon64Cost0[256];
  66. extern unsigned int shannon64Cost1[256];
  67. #endif