h264hwd_slice_header.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. -- Abstract : Decode slice header information from the stream
  17. --
  18. --------------------------------------------------------------------------------
  19. --
  20. -- Version control information, please leave untouched.
  21. --
  22. -- $RCSfile: h264hwd_slice_header.h,v $
  23. -- $Date: 2009/09/16 11:33:06 $
  24. -- $Revision: 1.3 $
  25. --
  26. ------------------------------------------------------------------------------*/
  27. /*------------------------------------------------------------------------------
  28. Table of contents
  29. 1. Include headers
  30. 2. Module defines
  31. 3. Data types
  32. 4. Function prototypes
  33. ------------------------------------------------------------------------------*/
  34. #ifndef H264HWD_SLICE_HEADER_H
  35. #define H264HWD_SLICE_HEADER_H
  36. /*------------------------------------------------------------------------------
  37. 1. Include headers
  38. ------------------------------------------------------------------------------*/
  39. #include "basetype.h"
  40. #include "h264hwd_stream.h"
  41. #include "h264hwd_cfg.h"
  42. #include "h264hwd_seq_param_set.h"
  43. #include "h264hwd_pic_param_set.h"
  44. #include "h264hwd_nal_unit.h"
  45. /*------------------------------------------------------------------------------
  46. 2. Module defines
  47. ------------------------------------------------------------------------------*/
  48. enum {
  49. P_SLICE = 0,
  50. B_SLICE = 1,
  51. I_SLICE = 2
  52. };
  53. enum {NO_LONG_TERM_FRAME_INDICES = 0xFFFF};
  54. /* macro to determine if slice is an inter slice, sliceTypes 0 and 5 */
  55. #define IS_P_SLICE(sliceType) (((sliceType) == P_SLICE) || \
  56. ((sliceType) == P_SLICE + 5))
  57. /* macro to determine if slice is an intra slice, sliceTypes 2 and 7 */
  58. #define IS_I_SLICE(sliceType) (((sliceType) == I_SLICE) || \
  59. ((sliceType) == I_SLICE + 5))
  60. #define IS_B_SLICE(sliceType) (((sliceType) == B_SLICE) || \
  61. ((sliceType) == B_SLICE + 5))
  62. /*------------------------------------------------------------------------------
  63. 3. Data types
  64. ------------------------------------------------------------------------------*/
  65. /* structure to store data of one reference picture list reordering operation */
  66. typedef struct
  67. {
  68. u32 reorderingOfPicNumsIdc;
  69. u32 absDiffPicNum;
  70. u32 longTermPicNum;
  71. } refPicListReorderingOperation_t;
  72. /* structure to store reference picture list reordering operations */
  73. typedef struct
  74. {
  75. u32 refPicListReorderingFlagL0;
  76. refPicListReorderingOperation_t command[MAX_NUM_REF_PICS+1];
  77. } refPicListReordering_t;
  78. /* structure to store data of one DPB memory management control operation */
  79. typedef struct
  80. {
  81. u32 memoryManagementControlOperation;
  82. u32 differenceOfPicNums;
  83. u32 longTermPicNum;
  84. u32 longTermFrameIdx;
  85. u32 maxLongTermFrameIdx;
  86. } memoryManagementOperation_t;
  87. /* worst case scenario: all MAX_NUM_REF_PICS pictures in the buffer are
  88. * short term pictures, each one of them is first marked as long term
  89. * reference picture which is then marked as unused for reference.
  90. * Additionally, max long-term frame index is set and current picture is
  91. * marked as long term reference picture. Last position reserved for
  92. * end memory_management_control_operation command */
  93. #define MAX_NUM_MMC_OPERATIONS (2*MAX_NUM_REF_PICS+2+1)
  94. /* structure to store decoded reference picture marking data */
  95. typedef struct
  96. {
  97. u32 strmLen;
  98. u32 noOutputOfPriorPicsFlag;
  99. u32 longTermReferenceFlag;
  100. u32 adaptiveRefPicMarkingModeFlag;
  101. memoryManagementOperation_t operation[MAX_NUM_MMC_OPERATIONS];
  102. } decRefPicMarking_t;
  103. /* structure to store slice header data decoded from the stream */
  104. typedef struct
  105. {
  106. u32 firstMbInSlice;
  107. u32 sliceType;
  108. u32 picParameterSetId;
  109. u32 frameNum;
  110. u32 idrPicId;
  111. u32 pocLength;
  112. u32 pocLengthHw;
  113. u32 picOrderCntLsb;
  114. i32 deltaPicOrderCntBottom;
  115. i32 deltaPicOrderCnt[2];
  116. u32 redundantPicCnt;
  117. u32 numRefIdxActiveOverrideFlag;
  118. u32 numRefIdxL0Active;
  119. u32 numRefIdxL1Active;
  120. i32 sliceQpDelta;
  121. u32 disableDeblockingFilterIdc;
  122. i32 sliceAlphaC0Offset;
  123. i32 sliceBetaOffset;
  124. u32 sliceGroupChangeCycle;
  125. refPicListReordering_t refPicListReordering;
  126. refPicListReordering_t refPicListReorderingL1;
  127. decRefPicMarking_t decRefPicMarking;
  128. u32 cabacInitIdc;
  129. u32 fieldPicFlag;
  130. u32 bottomFieldFlag;
  131. u32 directSpatialMvPredFlag;
  132. } sliceHeader_t;
  133. /*------------------------------------------------------------------------------
  134. 4. Function prototypes
  135. ------------------------------------------------------------------------------*/
  136. u32 h264bsdDecodeSliceHeader(strmData_t *pStrmData,
  137. sliceHeader_t *pSliceHeader,
  138. seqParamSet_t *pSeqParamSet,
  139. picParamSet_t *pPicParamSet,
  140. nalUnit_t *pNalUnit);
  141. u32 h264bsdCheckPpsId(strmData_t *pStrmData, u32 *ppsId);
  142. u32 h264bsdCheckFrameNum(
  143. strmData_t *pStrmData,
  144. u32 maxFrameNum,
  145. u32 *frameNum);
  146. u32 h264bsdCheckIdrPicId(
  147. strmData_t *pStrmData,
  148. u32 maxFrameNum,
  149. nalUnitType_e nalUnitType,
  150. u32 fieldPicFlag,
  151. u32 *idrPicId);
  152. u32 h264bsdCheckPicOrderCntLsb(
  153. strmData_t *pStrmData,
  154. seqParamSet_t *pSeqParamSet,
  155. nalUnitType_e nalUnitType,
  156. u32 *picOrderCntLsb);
  157. u32 h264bsdCheckDeltaPicOrderCntBottom(
  158. strmData_t *pStrmData,
  159. seqParamSet_t *pSeqParamSet,
  160. nalUnitType_e nalUnitType,
  161. i32 *deltaPicOrderCntBottom);
  162. u32 h264bsdCheckDeltaPicOrderCnt(
  163. strmData_t *pStrmData,
  164. seqParamSet_t *pSeqParamSet,
  165. nalUnitType_e nalUnitType,
  166. u32 picOrderPresentFlag,
  167. i32 *deltaPicOrderCnt);
  168. u32 h264bsdCheckRedundantPicCnt(
  169. const strmData_t *pStrmData,
  170. const seqParamSet_t *pSeqParamSet,
  171. const picParamSet_t *pPicParamSet,
  172. nalUnitType_e nalUnitType,
  173. u32 *redundantPicCnt);
  174. u32 h264bsdCheckPriorPicsFlag(u32 * noOutputOfPriorPicsFlag,
  175. const strmData_t * pStrmData,
  176. const seqParamSet_t * pSeqParamSet,
  177. const picParamSet_t * pPicParamSet,
  178. nalUnitType_e nalUnitType);
  179. u32 h264bsdFieldPicFlag(strmData_t * pStrmData,
  180. u32 maxFrameNum,
  181. nalUnitType_e nalUnitType,
  182. u32 fieldPicFlagPresent,
  183. u32 *fieldPicFlag);
  184. u32 h264bsdBottomFieldFlag(strmData_t * pStrmData,
  185. u32 maxFrameNum,
  186. nalUnitType_e nalUnitType,
  187. u32 fieldPicFlag,
  188. u32 *bottomFieldFlag);
  189. u32 h264bsdIsOppositeFieldPic(sliceHeader_t * pSliceCurr,
  190. sliceHeader_t * pSlicePrev,
  191. u32 *secondField, u32 prevRefFrameNum,
  192. u32 newPicture);
  193. u32 h264bsdCheckFieldPicFlag(strmData_t * pStrmData,
  194. u32 maxFrameNum,
  195. nalUnitType_e nalUnitType,
  196. u32 fieldPicFlagPresent,
  197. u32 *fieldPicFlag);
  198. u32 h264bsdCheckBottomFieldFlag(strmData_t * pStrmData,
  199. u32 maxFrameNum,
  200. nalUnitType_e nalUnitType, u32 fieldPicFlag,
  201. u32 * bottomFieldFlag);
  202. u32 h264bsdCheckFirstMbInSlice(strmData_t * pStrmData,
  203. nalUnitType_e nalUnitType,
  204. u32 * firstMbInSlice);
  205. #endif /* #ifdef H264HWD_SLICE_HEADER_H */