1
0

defines.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /*!
  2. **************************************************************************
  3. * \file defines.h
  4. *
  5. * \brief
  6. * Header file containing some useful global definitions
  7. *
  8. * \author
  9. * Main contributors (see contributors.h for copyright, address and affiliation details)
  10. * - Detlev Marpe
  11. * - Karsten Sühring <[email protected]>
  12. * - Alexis Michael Tourapis <[email protected]>
  13. *
  14. *
  15. * \date
  16. * 21. March 2001
  17. **************************************************************************
  18. */
  19. #ifndef H264_DEFINES_H_
  20. #define H264_DEFINES_H_
  21. #pragma once
  22. #if defined _DEBUG
  23. # define TRACE 0 //!< 0:Trace off 1:Trace on 2:detailed CABAC context information
  24. #else
  25. # define TRACE 0 //!< 0:Trace off 1:Trace on 2:detailed CABAC context information
  26. #endif
  27. #define JM "16.1 (FRExt)"
  28. #define VERSION "16.1"
  29. #define EXT_VERSION "(FRExt)"
  30. #define DUMP_DPB 0 //!< Dump DPB info for debug purposes
  31. #define PAIR_FIELDS_IN_OUTPUT 0 //!< Pair field pictures for output purposes
  32. #define IMGTYPE 0 //!< Define imgpel size type. 0 implies byte (cannot handle >8 bit depths) and 1 implies unsigned short
  33. #define ENABLE_FIELD_CTX 1 //!< Enables Field mode related context types for CABAC
  34. #define ENABLE_HIGH444_CTX 1 //!< Enables High 444 profile context types for CABAC.
  35. #define ZEROSNR 0 //!< PSNR computation method
  36. #define ENABLE_OUTPUT_TONEMAPPING 1 //!< enable tone map the output if tone mapping SEI present
  37. #include "typedefs.h"
  38. #define H264_MEMORY_ALIGNMENT 32
  39. //#define MAX_NUM_SLICES 150
  40. #define MAX_NUM_SLICES 50
  41. #define MAX_REFERENCE_PICTURES 32 //!< H.264 allows 32 fields
  42. #define MAX_CODED_FRAME_SIZE 8000000 //!< bytes for one frame
  43. //AVC Profile IDC definitions
  44. #define BASELINE 66 //!< YUV 4:2:0/8 "Baseline"
  45. #define MAIN 77 //!< YUV 4:2:0/8 "Main"
  46. #define EXTENDED 88 //!< YUV 4:2:0/8 "Extended"
  47. #define FREXT_HP 100 //!< YUV 4:2:0/8 "High"
  48. #define FREXT_Hi10P 110 //!< YUV 4:2:0/10 "High 10"
  49. #define FREXT_Hi422 122 //!< YUV 4:2:2/10 "High 4:2:2"
  50. #define FREXT_Hi444 244 //!< YUV 4:4:4/14 "High 4:4:4"
  51. #define FREXT_CAVLC444 44 //!< YUV 4:4:4/14 "CAVLC 4:4:4"
  52. #define FILE_NAME_SIZE 255
  53. #define INPUT_TEXT_SIZE 1024
  54. #if (ENABLE_HIGH444_CTX == 1)
  55. # define NUM_BLOCK_TYPES 22
  56. #else
  57. # define NUM_BLOCK_TYPES 10
  58. #endif
  59. //#define _LEAKYBUCKET_
  60. #define BLOCK_SHIFT 2
  61. #define BLOCK_SIZE 4
  62. #define BLOCK_SIZE_8x8 8
  63. #define SMB_BLOCK_SIZE 8
  64. #define BLOCK_PIXELS 16
  65. #define MB_BLOCK_SIZE 16
  66. #define MB_PIXELS 256 // MB_BLOCK_SIZE * MB_BLOCK_SIZE
  67. #define MB_PIXELS_SHIFT 8 // log2(MB_BLOCK_SIZE * MB_BLOCK_SIZE)
  68. #define MB_BLOCK_SHIFT 4
  69. #define BLOCK_MULTIPLE 4 // (MB_BLOCK_SIZE/BLOCK_SIZE)
  70. #define MB_BLOCK_PARTITIONS 16 // (BLOCK_MULTIPLE * BLOCK_MULTIPLE)
  71. #define BLOCK_CONTEXT 64 // (4 * MB_BLOCK_PARTITIONS)
  72. // These variables relate to the subpel accuracy supported by the software (1/4)
  73. #define BLOCK_SIZE_SP 16 // BLOCK_SIZE << 2
  74. #define BLOCK_SIZE_8x8_SP 32 // BLOCK_SIZE8x8 << 2
  75. // Available MB modes
  76. enum {
  77. PSKIP = 0,
  78. BSKIP_DIRECT = 0,
  79. P16x16 = 1,
  80. P16x8 = 2,
  81. P8x16 = 3,
  82. SMB8x8 = 4,
  83. SMB8x4 = 5,
  84. SMB4x8 = 6,
  85. SMB4x4 = 7,
  86. P8x8 = 8,
  87. I4MB = 9,
  88. I16MB = 10,
  89. IBLOCK = 11,
  90. SI4MB = 12,
  91. I8MB = 13,
  92. IPCM = 14,
  93. MAXMODE = 15
  94. } ;//MBModeTypes;
  95. // number of intra prediction modes
  96. #define NO_INTRA_PMODE 9
  97. // Direct Mode types
  98. enum {
  99. DIR_TEMPORAL = 0, //!< Temporal Direct Mode
  100. DIR_SPATIAL = 1 //!< Spatial Direct Mode
  101. } ;//DirectModes;
  102. // CAVLC block types
  103. enum {
  104. LUMA = 0,
  105. LUMA_INTRA16x16DC = 1,
  106. LUMA_INTRA16x16AC = 2,
  107. CB = 3,
  108. CB_INTRA16x16DC = 4,
  109. CB_INTRA16x16AC = 5,
  110. CR = 8,
  111. CR_INTRA16x16DC = 9,
  112. CR_INTRA16x16AC = 10
  113. } ;//CAVLCBlockTypes;
  114. // CABAC block types
  115. enum {
  116. LUMA_16DC = 0,
  117. LUMA_16AC = 1,
  118. LUMA_8x8 = 2,
  119. LUMA_8x4 = 3,
  120. LUMA_4x8 = 4,
  121. LUMA_4x4 = 5,
  122. CHROMA_DC = 6,
  123. CHROMA_AC = 7,
  124. CHROMA_DC_2x4 = 8,
  125. CHROMA_DC_4x4 = 9,
  126. CB_16DC = 10,
  127. CB_16AC = 11,
  128. CB_8x8 = 12,
  129. CB_8x4 = 13,
  130. CB_4x8 = 14,
  131. CB_4x4 = 15,
  132. CR_16DC = 16,
  133. CR_16AC = 17,
  134. CR_8x8 = 18,
  135. CR_8x4 = 19,
  136. CR_4x8 = 20,
  137. CR_4x4 = 21
  138. } ;//CABACBlockTypes;
  139. // Macro defines
  140. #define Q_BITS 15
  141. #define DQ_BITS 6
  142. #define Q_BITS_8 16
  143. #define DQ_BITS_8 6
  144. //#define IS_INTRA(MB) ((MB)->mb_type==I4MB || (MB)->mb_type==I16MB ||(MB)->mb_type==IPCM || (MB)->mb_type==I8MB || (MB)->mb_type==SI4MB)
  145. #define IS_INTRA(MB) (!!((1 << (MB)->mb_type) & ((1<<I4MB) | (1<<I16MB) | (1<<IPCM) | (1<<I8MB) | (1<<SI4MB))))
  146. #define IS_I16MB(MB) ((MB)->mb_type==I16MB || (MB)->mb_type==IPCM)
  147. #define IS_INTER(MB) (!IS_INTRA(MB))
  148. //#define IS_INTER(MB) ((MB)->mb_type!=SI4MB && (MB)->mb_type!=I4MB && (MB)->mb_type!=I16MB && (MB)->mb_type!=I8MB && (MB)->mb_type!=IPCM)
  149. #define IS_INTERMV(MB) ((MB)->mb_type!=I4MB && (MB)->mb_type!=I16MB && (MB)->mb_type!=I8MB && (MB)->mb_type!=0 && (MB)->mb_type!=IPCM)
  150. #define IS_DIRECT(MB) ((MB)->mb_type==0 && (currSlice->slice_type == B_SLICE ))
  151. #define IS_SKIP(MB) ((MB)->mb_type==0 && (currSlice->slice_type == P_SLICE || currSlice->slice_type == SP_SLICE))
  152. #define TOTRUN_NUM 15
  153. #define RUNBEFORE_NUM 7
  154. #define RUNBEFORE_NUM_M1 6
  155. // Quantization parameter range
  156. #define MIN_QP 0
  157. #define MAX_QP 51
  158. // 4x4 intra prediction modes
  159. enum {
  160. VERT_PRED = 0,
  161. HOR_PRED = 1,
  162. DC_PRED = 2,
  163. DIAG_DOWN_LEFT_PRED = 3,
  164. DIAG_DOWN_RIGHT_PRED = 4,
  165. VERT_RIGHT_PRED = 5,
  166. HOR_DOWN_PRED = 6,
  167. VERT_LEFT_PRED = 7,
  168. HOR_UP_PRED = 8
  169. } ;//I4x4PredModes;
  170. // 16x16 intra prediction modes
  171. enum {
  172. VERT_PRED_16 = 0,
  173. HOR_PRED_16 = 1,
  174. DC_PRED_16 = 2,
  175. PLANE_16 = 3
  176. } ;//I16x16PredModes;
  177. // 8x8 chroma intra prediction modes
  178. enum {
  179. DC_PRED_8 = 0,
  180. HOR_PRED_8 = 1,
  181. VERT_PRED_8 = 2,
  182. PLANE_8 = 3
  183. } ;//I8x8PredModes;
  184. enum {
  185. EOS = 1, //!< End Of Sequence
  186. SOP = 2, //!< Start Of Picture
  187. SOS = 3 //!< Start Of Slice
  188. };
  189. // MV Prediction types
  190. enum {
  191. MVPRED_MEDIAN = 0,
  192. MVPRED_L = 1,
  193. MVPRED_U = 2,
  194. MVPRED_UR = 3
  195. } ;//MVPredTypes;
  196. enum {
  197. DECODING_OK = 0,
  198. SEARCH_SYNC = 1,
  199. PICTURE_DECODED = 2
  200. };
  201. #define LAMBDA_ACCURACY_BITS 16
  202. #define INVALIDINDEX (-135792468)
  203. #define RC_MAX_TEMPORAL_LEVELS 5
  204. //Start code and Emulation Prevention need this to be defined in identical manner at encoder and decoder
  205. #define ZEROBYTES_SHORTSTARTCODE 2 //indicates the number of zero bytes in the short start-code prefix
  206. #define MAX_PLANE 3
  207. #define IS_INDEPENDENT(IMG) ((IMG)->separate_colour_plane_flag)
  208. #define IS_FREXT_PROFILE(profile_idc) ( profile_idc>=FREXT_HP || profile_idc == FREXT_CAVLC444 )
  209. #define HI_INTRA_ONLY_PROFILE (((p_Vid->active_sps->profile_idc>=FREXT_Hi10P)&&(p_Vid->active_sps->constrained_set3_flag))||(p_Vid->active_sps->profile_idc==FREXT_CAVLC444))
  210. enum
  211. {
  212. VUI_AR_UNDEFINED = 0,
  213. VUI_AR_SQUARE = 1, // 1:1
  214. VUI_AR_12_11 = 2, // 12:11
  215. VUI_AR_10_11 = 3, // 10:11
  216. VUI_AR_16_11 = 4, // 16:11
  217. VUI_AR_40_33 = 5, // 40:33
  218. VUI_AR_24_11 = 6, // 24:11
  219. VUI_AR_20_11 = 7, // 20:11
  220. VUI_AR_32_11 = 8, // 32:11
  221. VUI_AR_80_33 = 9, // 80:33
  222. VUI_AR_18_11 = 10, // 18:11
  223. VUI_AR_15_11 = 11, // 15:11
  224. VUI_AR_64_33 = 12, // 64:33
  225. VUI_AR_160_99 = 13, // 160:99
  226. VUI_AR_4_3 = 14, // 4:3
  227. VUI_AR_3_2 = 15, // 3:2
  228. VUI_AR_2_1 = 16, // 2:1
  229. VUI_EXTENDED_SAR = 255,
  230. };
  231. #endif