huffman.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /****************************************************************************
  2. *
  3. * Module Title : Huffman.h
  4. *
  5. * Description : Video CODEC
  6. *
  7. * AUTHOR : Paul Wilkins
  8. *
  9. *****************************************************************************
  10. * Revision History
  11. *
  12. * 1.04 YWX 06-Nov-01 Changed for compatibility with Equator C compiler
  13. * 1.03 JBB 26 Jan 01 New Huffman Code
  14. * 1.02 PGW 11 Oct 00 Deleted reference to FrequencyCounts[].
  15. * 1.01 PGW 15/03/00 Changes re. updated entropy tables.
  16. * 1.00 PGW 12/10/99 Configuration baseline
  17. *
  18. *****************************************************************************
  19. */
  20. #ifndef HUFFMAN_H
  21. #define HUFFMAN_H
  22. #include "type_aliases.h"
  23. #include "boolhuff.h"
  24. /****************************************************************************
  25. * Constants
  26. *****************************************************************************
  27. */
  28. /****************************************************************************/
  29. /****************************************************************************
  30. * Types
  31. *****************************************************************************
  32. */
  33. typedef struct _tokenorptr
  34. {
  35. unsigned int selector : 1; // 1 bit selector 0->ptr, 1->token
  36. unsigned int value : 7;
  37. } tokenorptr;
  38. typedef struct _huffnode
  39. {
  40. union
  41. {
  42. char l;
  43. tokenorptr left;
  44. } leftunion;
  45. union
  46. {
  47. char r;
  48. tokenorptr right;
  49. } rightunion;
  50. unsigned char freq;
  51. } HUFF_NODE;
  52. /****************************************************************************
  53. * Data structures
  54. *****************************************************************************
  55. */
  56. /****************************************************************************
  57. * Functions
  58. *****************************************************************************
  59. */
  60. extern void VP5_BuildHuffTree(
  61. HUFF_NODE *hn,
  62. unsigned int *counts,
  63. int values );
  64. extern void VP5_CreateCodeArray( HUFF_NODE *hn,
  65. int node,
  66. unsigned int *codearray,
  67. unsigned char *lengtharray,
  68. int codevalue,
  69. int codelength );
  70. extern void VP5_EncodeValue(
  71. BOOL_CODER *bc,
  72. HUFF_NODE *hn,
  73. int value,
  74. int length);
  75. #endif