codec_def.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*!
  2. * \copy
  3. * Copyright (c) 2013, Cisco Systems
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. *
  13. * * Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in
  15. * the documentation and/or other materials provided with the
  16. * distribution.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  21. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  22. * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  23. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  24. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  26. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  28. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  29. * POSSIBILITY OF SUCH DAMAGE.
  30. *
  31. */
  32. #ifndef WELS_VIDEO_CODEC_DEFINITION_H__
  33. #define WELS_VIDEO_CODEC_DEFINITION_H__
  34. /**
  35. * @file codec_def.h
  36. */
  37. /**
  38. * @brief Enumerate the type of video format
  39. */
  40. typedef enum {
  41. videoFormatRGB = 1, ///< rgb color formats
  42. videoFormatRGBA = 2,
  43. videoFormatRGB555 = 3,
  44. videoFormatRGB565 = 4,
  45. videoFormatBGR = 5,
  46. videoFormatBGRA = 6,
  47. videoFormatABGR = 7,
  48. videoFormatARGB = 8,
  49. videoFormatYUY2 = 20, ///< yuv color formats
  50. videoFormatYVYU = 21,
  51. videoFormatUYVY = 22,
  52. videoFormatI420 = 23, ///< the same as IYUV
  53. videoFormatYV12 = 24,
  54. videoFormatInternal = 25, ///< only used in SVC decoder testbed
  55. videoFormatNV12 = 26, ///< new format for output by DXVA decoding
  56. videoFormatVFlip = 0x80000000
  57. } EVideoFormatType;
  58. /**
  59. * @brief Enumerate video frame type
  60. */
  61. typedef enum {
  62. videoFrameTypeInvalid, ///< encoder not ready or parameters are invalidate
  63. videoFrameTypeIDR, ///< IDR frame in H.264
  64. videoFrameTypeI, ///< I frame type
  65. videoFrameTypeP, ///< P frame type
  66. videoFrameTypeSkip, ///< skip the frame based encoder kernel
  67. videoFrameTypeIPMixed ///< a frame where I and P slices are mixing, not supported yet
  68. } EVideoFrameType;
  69. /**
  70. * @brief Enumerate return type
  71. */
  72. typedef enum {
  73. cmResultSuccess, ///< successful
  74. cmInitParaError, ///< parameters are invalid
  75. cmUnknownReason,
  76. cmMallocMemeError, ///< malloc a memory error
  77. cmInitExpected, ///< initial action is expected
  78. cmUnsupportedData
  79. } CM_RETURN;
  80. /**
  81. * @brief Enumulate the nal unit type
  82. */
  83. enum ENalUnitType {
  84. NAL_UNKNOWN = 0,
  85. NAL_SLICE = 1,
  86. NAL_SLICE_DPA = 2,
  87. NAL_SLICE_DPB = 3,
  88. NAL_SLICE_DPC = 4,
  89. NAL_SLICE_IDR = 5, ///< ref_idc != 0
  90. NAL_SEI = 6, ///< ref_idc == 0
  91. NAL_SPS = 7,
  92. NAL_PPS = 8
  93. ///< ref_idc == 0 for 6,9,10,11,12
  94. };
  95. /**
  96. * @brief NRI: eNalRefIdc
  97. */
  98. enum ENalPriority {
  99. NAL_PRIORITY_DISPOSABLE = 0,
  100. NAL_PRIORITY_LOW = 1,
  101. NAL_PRIORITY_HIGH = 2,
  102. NAL_PRIORITY_HIGHEST = 3
  103. };
  104. #define IS_PARAMETER_SET_NAL(eNalRefIdc, eNalType) \
  105. ( (eNalRefIdc == NAL_PRIORITY_HIGHEST) && (eNalType == (NAL_SPS|NAL_PPS) || eNalType == NAL_SPS) )
  106. #define IS_IDR_NAL(eNalRefIdc, eNalType) \
  107. ( (eNalRefIdc == NAL_PRIORITY_HIGHEST) && (eNalType == NAL_SLICE_IDR) )
  108. #define FRAME_NUM_PARAM_SET (-1)
  109. #define FRAME_NUM_IDR 0
  110. /**
  111. * @brief eDeblockingIdc
  112. */
  113. enum {
  114. DEBLOCKING_IDC_0 = 0,
  115. DEBLOCKING_IDC_1 = 1,
  116. DEBLOCKING_IDC_2 = 2
  117. };
  118. #define DEBLOCKING_OFFSET (6)
  119. #define DEBLOCKING_OFFSET_MINUS (-6)
  120. /* Error Tools definition */
  121. typedef unsigned short ERR_TOOL;
  122. /**
  123. @brief to do
  124. */
  125. enum {
  126. ET_NONE = 0x00, ///< NONE Error Tools
  127. ET_IP_SCALE = 0x01, ///< IP Scalable
  128. ET_FMO = 0x02, ///< Flexible Macroblock Ordering
  129. ET_IR_R1 = 0x04, ///< Intra Refresh in predifined 2% MB
  130. ET_IR_R2 = 0x08, ///< Intra Refresh in predifined 5% MB
  131. ET_IR_R3 = 0x10, ///< Intra Refresh in predifined 10% MB
  132. ET_FEC_HALF = 0x20, ///< Forward Error Correction in 50% redundency mode
  133. ET_FEC_FULL = 0x40, ///< Forward Error Correction in 100% redundency mode
  134. ET_RFS = 0x80 ///< Reference Frame Selection
  135. };
  136. /**
  137. * @brief Information of coded Slice(=NAL)(s)
  138. */
  139. typedef struct SliceInformation {
  140. unsigned char* pBufferOfSlices; ///< base buffer of coded slice(s)
  141. int iCodedSliceCount; ///< number of coded slices
  142. unsigned int* pLengthOfSlices; ///< array of slices length accordingly by number of slice
  143. int iFecType; ///< FEC type[0, 50%FEC, 100%FEC]
  144. unsigned char uiSliceIdx; ///< index of slice in frame [FMO: 0,..,uiSliceCount-1; No FMO: 0]
  145. unsigned char uiSliceCount; ///< count number of slice in frame [FMO: 2-8; No FMO: 1]
  146. char iFrameIndex; ///< index of frame[-1, .., idr_interval-1]
  147. unsigned char uiNalRefIdc; ///< NRI, priority level of slice(NAL)
  148. unsigned char uiNalType; ///< NAL type
  149. unsigned char
  150. uiContainingFinalNal; ///< whether final NAL is involved in buffer of coded slices, flag used in Pause feature in T27
  151. } SliceInfo, *PSliceInfo;
  152. /**
  153. * @brief thresholds of the initial, maximal and minimal rate
  154. */
  155. typedef struct {
  156. int iWidth; ///< frame width
  157. int iHeight; ///< frame height
  158. int iThresholdOfInitRate; ///< threshold of initial rate
  159. int iThresholdOfMaxRate; ///< threshold of maximal rate
  160. int iThresholdOfMinRate; ///< threshold of minimal rate
  161. int iMinThresholdFrameRate; ///< min frame rate min
  162. int iSkipFrameRate; ///< skip to frame rate min
  163. int iSkipFrameStep; ///< how many frames to skip
  164. } SRateThresholds, *PRateThresholds;
  165. /**
  166. * @brief Structure for decoder memery
  167. */
  168. typedef struct TagSysMemBuffer {
  169. int iWidth; ///< width of decoded pic for display
  170. int iHeight; ///< height of decoded pic for display
  171. int iFormat; ///< type is "EVideoFormatType"
  172. int iStride[2]; ///< stride of 2 component
  173. } SSysMEMBuffer;
  174. /**
  175. * @brief Buffer info
  176. */
  177. typedef struct TagBufferInfo {
  178. int iBufferStatus; ///< 0: one frame data is not ready; 1: one frame data is ready
  179. unsigned long long uiInBsTimeStamp; ///< input BS timestamp
  180. unsigned long long uiOutYuvTimeStamp; ///< output YUV timestamp, when bufferstatus is 1
  181. union {
  182. SSysMEMBuffer sSystemBuffer; ///< memory info for one picture
  183. } UsrData; ///< output buffer info
  184. } SBufferInfo;
  185. /**
  186. * @brief In a GOP, multiple of the key frame number, derived from
  187. * the number of layers(index or array below)
  188. */
  189. static const char kiKeyNumMultiple[] = {
  190. 1, 1, 2, 4, 8, 16,
  191. };
  192. #endif//WELS_VIDEO_CODEC_DEFINITION_H__