enccommon.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*------------------------------------------------------------------------------
  2. -- --
  3. -- This software is confidential and proprietary and may be used --
  4. -- only as expressly authorized by a licensing agreement from --
  5. -- --
  6. -- Hantro Products Oy. --
  7. -- --
  8. -- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
  9. -- ALL RIGHTS RESERVED --
  10. -- --
  11. -- The entire notice above must be reproduced --
  12. -- on all copies and should not be removed. --
  13. -- --
  14. --------------------------------------------------------------------------------
  15. --
  16. -- Description : Encoder common definitions for control code and system model
  17. --
  18. ------------------------------------------------------------------------------*/
  19. #ifndef __ENC_COMMON_H__
  20. #define __ENC_COMMON_H__
  21. /*------------------------------------------------------------------------------
  22. 1. External compiler flags
  23. ------------------------------------------------------------------------------*/
  24. /* Encoder global definitions
  25. *
  26. * _ASSERT_USED # Asserts enabled
  27. * _DEBUG_PRINT # Prints debug information on stdout
  28. * TRACE_STREAM # Creates stream trace file
  29. * TEST_DATA # Creates test data files
  30. * MPEG4_HW_VLC_MODE_ENABLED # Control: MPEG-4 ASIC supports VLC mode
  31. * MPEG4_HW_RLC_MODE_ENABLED # Control: MPEG-4 ASIC supports RLC mode
  32. * LOEFFLER_DCT # System: MPEG-4 DCT using SW algorithm
  33. * LOEFFLER_ASIC_DCT # System: MPEG-4 DCT using ASIC algorithm
  34. * LOEFFLER_IDCT # System: MPEG-4 IDCT using SW algorithm
  35. * LOEFFLER_ASIC_IDCT # System: MPEG-4 IDCT using ASIC algorithm
  36. * SW_QUANT # System: MPEG-4 quantization using SW algorithm
  37. * FIXED_POINT_QUANT # System: MPEG-4 quantization using ASIC algorithm
  38. *
  39. * Can be defined here or using compiler flags */
  40. #define LOEFFLER_ASIC_DCT
  41. #define LOEFFLER_ASIC_IDCT
  42. #define FIXED_POINT_QUANT
  43. /*------------------------------------------------------------------------------
  44. 2. Include headers
  45. ------------------------------------------------------------------------------*/
  46. #include "basetype.h"
  47. #include "ewl.h"
  48. /* Test data generation requires stream trace */
  49. #ifdef TEST_DATA
  50. #ifndef TRACE_STREAM
  51. #define TRACE_STREAM
  52. #endif
  53. #endif
  54. /* Stream tracing requires encdebug.h */
  55. #ifdef TRACE_STREAM
  56. #ifndef H8290_HAVE_ENCDEBUG_H
  57. #define H8290_HAVE_ENCDEBUG_H
  58. #endif
  59. #endif
  60. #ifdef H8290_HAVE_ENCDEBUG_H
  61. #include "encdebug.h"
  62. #else
  63. #define ASSERT(expr)
  64. #define DEBUG_PRINT(args)
  65. #define COMMENT(x)
  66. #define COMMENTMBTYPE(x,y)
  67. #define TRACE_BIT_STREAM(v,n)
  68. #endif
  69. #ifdef H8290_HAVE_ENCTRACE_H
  70. #include "enctrace.h"
  71. #endif
  72. /*------------------------------------------------------------------------------
  73. 3. Module defines
  74. ------------------------------------------------------------------------------*/
  75. typedef enum
  76. {
  77. ENCHW_NOK = -1,
  78. ENCHW_OK = 0
  79. } bool_e;
  80. typedef enum
  81. {
  82. ENCHW_NO = 0,
  83. ENCHW_YES = 1
  84. } true_e;
  85. typedef enum
  86. {
  87. NONIDR = 1, /* Coded slice of a non-IDR picture */
  88. IDR = 5, /* Coded slice of an IDR picture */
  89. SEI = 6, /* SEI message */
  90. SPSET = 7, /* Sequence parameter set */
  91. PPSET = 8, /* Picture parameter set */
  92. ENDOFSEQUENCE = 10, /* End of sequence */
  93. ENDOFSTREAM = 11, /* End of stream */
  94. FILLERDATA = 12, /* Filler data */
  95. PREFIX = 14, /* Prefix */
  96. SSPSET = 15, /* Subset sequence parameter set */
  97. MVC = 20 /* Coded slice of a view picture */
  98. } nalUnitType_e;
  99. /* VLC TABLE */
  100. typedef struct
  101. {
  102. i32 value; /* Value of bits */
  103. i32 number; /* Number of bits */
  104. } table_s;
  105. /* used in stream buffer handling */
  106. typedef struct
  107. {
  108. u8 *stream; /* Pointer to next byte of stream */
  109. u32 size; /* Byte size of stream buffer */
  110. u32 byteCnt; /* Byte counter */
  111. u32 bitCnt; /* Bit counter */
  112. u32 byteBuffer; /* Byte buffer */
  113. u32 bufferedBits; /* Amount of bits in byte buffer, [0-7] */
  114. u32 zeroBytes; /* Amount of consecutive zero bytes */
  115. i32 overflow; /* This will signal a buffer overflow */
  116. u32 emulCnt; /* Counter for emulation_3_byte, needed in SEI */
  117. i32 *table; /* Video packet or Gob sizes */
  118. i32 tableSize; /* Size of above table */
  119. i32 tableCnt; /* Table counter of above table */
  120. } stream_s;
  121. /* General tools */
  122. #define ABS(x) ((x) < (0) ? -(x) : (x))
  123. #define MAX(a, b) ((a) > (b) ? (a) : (b))
  124. #define MIN(a, b) ((a) < (b) ? (a) : (b))
  125. #define SIGN(a) ((a) < (0) ? (-1) : (1))
  126. #endif