h264hwd_dpb.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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 : Decoded Picture Buffer (DPB) handling
  17. --
  18. --------------------------------------------------------------------------------
  19. --
  20. -- Version control information, please leave untouched.
  21. --
  22. -- $RCSfile: h264hwd_dpb.h,v $
  23. -- $Date: 2010/01/12 07:06:02 $
  24. -- $Revision: 1.11 $
  25. --
  26. ------------------------------------------------------------------------------*/
  27. #ifndef H264HWD_DPB_H
  28. #define H264HWD_DPB_H
  29. /*------------------------------------------------------------------------------
  30. 1. Include headers
  31. ------------------------------------------------------------------------------*/
  32. #include "basetype.h"
  33. #include "h264hwd_slice_header.h"
  34. #include "h264hwd_image.h"
  35. #include "dwl.h"
  36. /*------------------------------------------------------------------------------
  37. 2. Module defines
  38. ------------------------------------------------------------------------------*/
  39. /*------------------------------------------------------------------------------
  40. 3. Data types
  41. ------------------------------------------------------------------------------*/
  42. /* enumeration to represent status of buffered image */
  43. typedef enum
  44. {
  45. UNUSED = 0,
  46. NON_EXISTING,
  47. SHORT_TERM,
  48. LONG_TERM,
  49. EMPTY
  50. } dpbPictureStatus_e;
  51. /* structure to represent a buffered picture */
  52. typedef struct dpbPicture
  53. {
  54. u32 memIdx;
  55. DWLLinearMem_t *data;
  56. i32 picNum;
  57. u32 frameNum;
  58. i32 picOrderCnt[2];
  59. dpbPictureStatus_e status[2];
  60. u32 toBeDisplayed;
  61. u32 picId;
  62. u32 numErrMbs;
  63. u32 isIdr;
  64. u32 isFieldPic;
  65. } dpbPicture_t;
  66. /* structure to represent display image output from the buffer */
  67. typedef struct
  68. {
  69. u32 memIdx;
  70. DWLLinearMem_t *data;
  71. u32 picId;
  72. u32 numErrMbs;
  73. u32 isIdr;
  74. u32 interlaced;
  75. u32 fieldPicture;
  76. u32 topField;
  77. } dpbOutPicture_t;
  78. /* structure to represent DPB */
  79. typedef struct dpbStorage
  80. {
  81. dpbPicture_t buffer[16 + 1];
  82. u32 list[16 + 1];
  83. dpbPicture_t *currentOut;
  84. u32 currentOutPos;
  85. dpbOutPicture_t *outBuf;
  86. u32 numOut;
  87. u32 outIndexW;
  88. u32 outIndexR;
  89. u32 maxRefFrames;
  90. u32 dpbSize;
  91. u32 maxFrameNum;
  92. u32 maxLongTermFrameIdx;
  93. u32 numRefFrames;
  94. u32 fullness;
  95. u32 prevRefFrameNum;
  96. u32 lastContainsMmco5;
  97. u32 noReordering;
  98. u32 flushed;
  99. u32 picSizeInMbs;
  100. u32 dirMvOffset;
  101. DWLLinearMem_t poc;
  102. u32 delayedOut;
  103. u32 delayedId;
  104. u32 interlaced;
  105. u32 ch2Offset;
  106. u32 numFreeBuffers;
  107. u32 freeBuffers[16+1];
  108. u32 memStat[16+1+16+1];
  109. u32 totBuffers;
  110. DWLLinearMem_t picBuffers[16+1+16+1];
  111. /* flag to prevent output when display smoothing is used and second field
  112. * of a picture was just decoded */
  113. u32 noOutput;
  114. u32 prevOutIdx;
  115. } dpbStorage_t;
  116. /*------------------------------------------------------------------------------
  117. 4. Function prototypes
  118. ------------------------------------------------------------------------------*/
  119. u32 h264bsdInitDpb(const void *dwl,
  120. dpbStorage_t * dpb,
  121. u32 picSizeInMbs,
  122. u32 dpbSize,
  123. u32 numRefFrames, u32 maxFrameNum, u32 noReordering,
  124. u32 displaySmoothing,
  125. u32 monoChrome, u32 isHighSupported, u32 enable2ndChroma);
  126. u32 h264bsdResetDpb(const void *dwl,
  127. dpbStorage_t * dpb,
  128. u32 picSizeInMbs,
  129. u32 dpbSize,
  130. u32 numRefFrames, u32 maxFrameNum, u32 noReordering,
  131. u32 displaySmoothing,
  132. u32 monoChrome, u32 isHighSupported, u32 enable2ndChroma);
  133. void h264bsdInitRefPicList(dpbStorage_t * dpb);
  134. void *h264bsdAllocateDpbImage(dpbStorage_t * dpb);
  135. i32 h264bsdGetRefPicData(const dpbStorage_t * dpb, u32 index);
  136. u8 *h264bsdGetRefPicDataVlcMode(const dpbStorage_t * dpb, u32 index,
  137. u32 fieldMode);
  138. u32 h264bsdReorderRefPicList(dpbStorage_t * dpb,
  139. refPicListReordering_t * order,
  140. u32 currFrameNum, u32 numRefIdxActive);
  141. u32 h264bsdMarkDecRefPic(dpbStorage_t * dpb,
  142. /*@null@ */ const decRefPicMarking_t * mark,
  143. const image_t * image, u32 frameNum, i32 *picOrderCnt,
  144. u32 isIdr, u32 picId, u32 numErrMbs);
  145. u32 h264bsdCheckGapsInFrameNum(dpbStorage_t * dpb, u32 frameNum, u32 isRefPic,
  146. u32 gapsAllowed);
  147. /*@null@*/ dpbOutPicture_t *h264bsdDpbOutputPicture(dpbStorage_t * dpb);
  148. void h264bsdFlushDpb(dpbStorage_t * dpb);
  149. void h264bsdFreeDpb(const void *dwl, dpbStorage_t * dpb);
  150. void ShellSort(dpbStorage_t * dpb, u32 *list, u32 type, i32 par);
  151. void ShellSortF(dpbStorage_t * dpb, u32 *list, u32 type, /*u32 parity,*/ i32 par);
  152. void SetPicNums(dpbStorage_t * dpb, u32 currFrameNum);
  153. void h264DpbUpdateOutputList(dpbStorage_t * dpb, const image_t * image);
  154. #endif /* #ifdef H264HWD_DPB_H */