tokenentropy.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /****************************************************************************
  2. *
  3. * Module Title : TokenEntropy.h
  4. *
  5. * Description : Video CODEC: Coefficient toke entropy header.
  6. *
  7. * AUTHOR : Paul Wilkins
  8. *
  9. *****************************************************************************
  10. * Revision History
  11. *
  12. * 1.01 PGW 27 Jun 01 Module created.
  13. *
  14. *****************************************************************************
  15. */
  16. /****************************************************************************
  17. * Header Files
  18. *****************************************************************************
  19. */
  20. /****************************************************************************
  21. * Header Frames
  22. *****************************************************************************
  23. */
  24. #ifndef TOKEN_ENTROPY_H
  25. #define TOKEN_ENTROPY_H
  26. #include "type_aliases.h"
  27. #include "boolhuff.h"
  28. #include "codec_common.h"
  29. #include "huffman.h"
  30. /****************************************************************************
  31. * Constants
  32. *****************************************************************************
  33. */
  34. // VP5 hufman table AC bands
  35. #define VP5_AC_BANDS 6
  36. // Tokens Value Extra Bits (range + sign)
  37. #define ZERO_TOKEN 0 //0 Extra Bits 0+0
  38. #define ONE_TOKEN 1 //1 Extra Bits 0+1
  39. #define TWO_TOKEN 2 //2 Extra Bits 0+1
  40. #define THREE_TOKEN 3 //3 Extra Bits 0+1
  41. #define FOUR_TOKEN 4 //4 Extra Bits 0+1
  42. #define DCT_VAL_CATEGORY1 5 //5-6 Extra Bits 1+1
  43. #define DCT_VAL_CATEGORY2 6 //7-10 Extra Bits 2+1
  44. #define DCT_VAL_CATEGORY3 7 //11-26 Extra Bits 4+1
  45. #define DCT_VAL_CATEGORY4 8 //11-26 Extra Bits 5+1
  46. #define DCT_VAL_CATEGORY5 9 //27-58 Extra Bits 5+1
  47. #define DCT_VAL_CATEGORY6 10 //59+ Extra Bits 11+1
  48. #define DCT_EOB_TOKEN 11 //EOB Extra Bits 0+0
  49. #define MAX_ENTROPY_TOKENS (DCT_EOB_TOKEN + 1)
  50. #define ILLEGAL_TOKEN 255
  51. #define TOKEN_CONTEXTS 6 // EOB, 0, 1, 2, 3-4, x
  52. #define CONTEXT_NODES (MAX_ENTROPY_TOKENS-7)
  53. #define PREC_CASES 3
  54. #define DC_PROBABILITY_UPDATE_THRESH 100
  55. #define ZERO_CONTEXT_NODE 0
  56. #define EOB_CONTEXT_NODE 1
  57. #define ONE_CONTEXT_NODE 2
  58. #define LOW_VAL_CONTEXT_NODE 3
  59. #define TWO_CONTEXT_NODE 4
  60. #define THREE_CONTEXT_NODE 5
  61. #define HIGH_LOW_CONTEXT_NODE 6
  62. #define CAT_ONE_CONTEXT_NODE 7
  63. #define CAT_THREEFOUR_CONTEXT_NODE 8
  64. #define CAT_THREE_CONTEXT_NODE 9
  65. #define CAT_FIVE_CONTEXT_NODE 10
  66. #define PROB_UPDATE_BASELINE_COST 7
  67. #define MAX_PROB 254
  68. #define DCT_MAX_VALUE 2048
  69. /****************************************************************************
  70. * Types
  71. *****************************************************************************
  72. */
  73. extern const UINT32 ProbCost[256];
  74. extern const UINT8 ExtraBitLengths_VP5[MAX_ENTROPY_TOKENS];
  75. extern const UINT32 DctRangeMinVals[MAX_ENTROPY_TOKENS];
  76. typedef struct LineEq
  77. {
  78. INT32 M;
  79. INT32 C;
  80. } LINE_EQ;
  81. extern const UINT8 DcUpdateProbs[2][MAX_ENTROPY_TOKENS-1];
  82. extern const UINT8 AcUpdateProbs[PREC_CASES][2][VP5_AC_BANDS][MAX_ENTROPY_TOKENS-1];
  83. extern const UINT8 PrevTokenIndex[MAX_ENTROPY_TOKENS];
  84. extern UINT8 PrecZeroRunLength[BLOCK_SIZE];
  85. /****************************************************************************
  86. * Data structures
  87. *****************************************************************************
  88. */
  89. // These table contains the normailized probabilities required to traverse the
  90. // entropy tree for DC and AC value tokens representing values >= 2
  91. // Probabilities are normalized to 8 bits and represent the likelyhood of a zero branch.
  92. /****************************************************************************
  93. * Functions
  94. *****************************************************************************
  95. */
  96. #endif