bits_api.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. #ifndef _BITS_API_H_
  2. #define _BITS_API_H_
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include "val_types_public.h"
  7. #include "hal_api.h"
  8. typedef VAL_UINT32_T(*fgPrepare32FN)(VAL_HANDLE_T * a_phBitsHandle);
  9. /**
  10. * @par Structure
  11. * VBITS_HANDLE_T
  12. * @par Description
  13. * This is a parameter for bitstream parsing utility related function
  14. */
  15. typedef struct __VBITS_HANDLE_T {
  16. VAL_HANDLE_T hHALHandle; /* /< HAL Handle */
  17. VAL_HANDLE_T hVALHandle; /* /< VAL Handle */
  18. VAL_MEM_ADDR_T BitsStart; /* /< Bits Start */
  19. VAL_MEMORY_T rHandleMem; /* /< Handle memory */
  20. VAL_UINT32_T nReadingMode; /* /< 0 for software, 1 for mmap, 2 for hardware */
  21. VAL_ULONG_T StartAddr; /* /< used for software mode fast access */
  22. VAL_ULONG_T nSize; /* /< Size */
  23. VAL_UINT32_T nBitCnt; /* /< bits count */
  24. VAL_UINT32_T nZeroCnt; /* /< zero count */
  25. VAL_UINT32_T Cur32Bits; /* /< current 32 bits */
  26. VAL_UINT32_T CurBitCnt; /* /< current bits count */
  27. VAL_UINT32_T n03RemoveCount; /* /< 03 Remove Count */
  28. VAL_UINT32_T n03CountBit; /* /< 03 Count Bit */
  29. VAL_INT32_T n03FirstIndex; /* /< 03 First Index */
  30. VAL_INT32_T n03SecondIndex; /* /< 03 Second Index */
  31. VAL_UINT32_T n03RemoveIgnore; /* /< 03 Remove Ignore */
  32. VAL_BOOL_T bFirstCheck; /* /< First Check */
  33. VAL_BOOL_T bEverRemove; /* /< Ever Remove */
  34. VAL_BOOL_T bIgnoreByBS; /* /< Ignore By BS */
  35. VAL_BOOL_T bEOF; /* /< EOF */
  36. fgPrepare32FN Prepare32Bits; /* /< Prepare 32 Bits */
  37. VAL_DRIVER_TYPE_T vFormat; /* /< Format */
  38. VAL_UINT32_T value; /* /< value */
  39. } VBITS_HANDLE_T;
  40. /**
  41. * @par Enumeration
  42. * VBITS_READTYPE_T
  43. * @par Description
  44. * This is the item used for bits read type
  45. */
  46. typedef enum VBITS_READTYPE_T {
  47. VBITS_SOFTWARE = 0, /* /< software */
  48. VBITS_MMAP, /* /< mmap */
  49. VBITS_HARDWARE, /* /< hardware */
  50. VBITS_MAX /* /< MAX value */
  51. } VBITS_READTYPE_T;
  52. /*=============================================================================
  53. * Function Declaration
  54. *===========================================================================*/
  55. /**
  56. * @par Function
  57. * eBufEnable
  58. * @par Description
  59. * The hal init & HW enable function
  60. * @param
  61. * a_phBitsHandle [IN/OUT] The bits handle
  62. * @param
  63. * hHALHandle [IN/OUT] The hal handle
  64. * @param
  65. * nMode [IN] VBITS_READTYPE_T
  66. * @param
  67. * vFormat [IN] VAL_DRIVER_TYPE_T
  68. * @par Returns
  69. * VAL_UINT32_T, return VAL_RESULT_NO_ERROR if success, return VAL_RESULT_UNKNOWN_ERROR if failed
  70. */
  71. VAL_UINT32_T eBufEnable(
  72. VAL_HANDLE_T *a_phBitsHandle,
  73. VAL_HANDLE_T hHALHandle,
  74. VAL_UINT32_T nMode,
  75. VAL_DRIVER_TYPE_T vFormat
  76. );
  77. /**
  78. * @par Function
  79. * eBufEnable
  80. * @par Description
  81. * The HW disable function
  82. * @param
  83. * a_phBitsHandle [IN/OUT] The bits handle
  84. * @param
  85. * hHALHandle [IN/OUT] The hal handle
  86. * @param
  87. * nMode [IN] VBITS_READTYPE_T
  88. * @param
  89. * vFormat [IN] VAL_DRIVER_TYPE_T
  90. * @par Returns
  91. * VAL_UINT32_T, return VAL_RESULT_NO_ERROR if success, return VAL_RESULT_UNKNOWN_ERROR if failed
  92. */
  93. VAL_UINT32_T eBufDisable(
  94. VAL_HANDLE_T *a_phBitsHandle,
  95. VAL_HANDLE_T hHALHandle,
  96. VAL_UINT32_T nMode,
  97. VAL_DRIVER_TYPE_T vFormat
  98. );
  99. /**
  100. * @par Function
  101. * eBufInit
  102. * @par Description
  103. * The common init function
  104. * @param
  105. * a_phBitsHandle [IN/OUT] The bits handle
  106. * @param
  107. * hVALHandle [IN/OUT] The val handle
  108. * @param
  109. * hHALHandle [IN/OUT] The hal handle
  110. * @param
  111. * rBufAddrStart [IN] The buffer start address
  112. * @param
  113. * nMode [IN] VBITS_READTYPE_T
  114. * @param
  115. * vFormat [IN] VAL_DRIVER_TYPE_T
  116. * @par Returns
  117. * VAL_RESULT_T, return VAL_RESULT_NO_ERROR if success, return others if failed
  118. */
  119. VAL_RESULT_T eBufInit(
  120. VAL_HANDLE_T *a_phBitsHandle,
  121. VAL_HANDLE_T hVALHandle,
  122. VAL_HANDLE_T hHALHandle,
  123. VAL_MEM_ADDR_T rBufAddrStart,
  124. VAL_UINT32_T nMode,
  125. VAL_DRIVER_TYPE_T vFormat
  126. );
  127. /**
  128. * @par Function
  129. * eBufDeinit
  130. * @par Description
  131. * The common deinit function
  132. * @param
  133. * a_phBitsHandle [IN/OUT] The bits handle
  134. * @par Returns
  135. * VAL_RESULT_T, return VAL_RESULT_NO_ERROR if success, return others if failed
  136. */
  137. VAL_RESULT_T eBufDeinit(VAL_HANDLE_T *a_phBitsHandle);
  138. /**
  139. * @par Function
  140. * eBufGetBitCnt
  141. * @par Description
  142. * The function is used to get current bit count
  143. * @param
  144. * a_phBitsHandle [IN/OUT] The bits handle
  145. * @par Returns
  146. * VAL_UINT32_T, return current bit count
  147. */
  148. VAL_UINT32_T eBufGetBitCnt(VAL_HANDLE_T *a_phBitsHandle);
  149. /**
  150. * @par Function
  151. * eBufGetBits
  152. * @par Description
  153. * The function is used to get current bits by numBits
  154. * @param
  155. * a_phBitsHandle [IN/OUT] The bits handle
  156. * @param
  157. * numBits [IN] The number bits
  158. * @par Returns
  159. * VAL_UINT32_T, return current bits by numBits
  160. */
  161. VAL_UINT32_T eBufGetBits(VAL_HANDLE_T *a_phBitsHandle, VAL_UINT32_T numBits);
  162. /**
  163. * @par Function
  164. * eBufNextBits
  165. * @par Description
  166. * The function is used to show current bits by numBits
  167. * @param
  168. * a_phBitsHandle [IN/OUT] The bits handle
  169. * @param
  170. * numBits [IN] The number bits
  171. * @par Returns
  172. * VAL_UINT32_T, return current bits by numBits
  173. */
  174. VAL_UINT32_T eBufNextBits(VAL_HANDLE_T *a_phBitsHandle, VAL_UINT32_T numBits);
  175. /**
  176. * @par Function
  177. * eBufGetUEGolomb
  178. * @par Description
  179. * The function is used to get unsigned EGolomb bits
  180. * @param
  181. * a_phBitsHandle [IN/OUT] The bits handle
  182. * @par Returns
  183. * VAL_UINT32_T, return current unsigned EGolomb bits
  184. */
  185. VAL_UINT32_T eBufGetUEGolomb(VAL_HANDLE_T *a_phBitsHandle);
  186. /**
  187. * @par Function
  188. * eBufGetSEGolomb
  189. * @par Description
  190. * The function is used to get signed EGolomb bits
  191. * @param
  192. * a_phBitsHandle [IN/OUT] The bits handle
  193. * @par Returns
  194. * VAL_INT32_T, return current signed EGolomb bits
  195. */
  196. VAL_INT32_T eBufGetSEGolomb(VAL_HANDLE_T *a_phBitsHandle);
  197. /**
  198. * @par Function
  199. * eBufCheckEOF
  200. * @par Description
  201. * The function is used to check EOF bitstream
  202. * @param
  203. * a_phBitsHandle [IN/OUT] The bits handle
  204. * @par Returns
  205. * VAL_BOOL_T, return EOF or not
  206. */
  207. VAL_BOOL_T eBufCheckEOF(VAL_HANDLE_T *a_phBitsHandle);
  208. /**
  209. * @par Function
  210. * eBufGetBufSize
  211. * @par Description
  212. * The function is used to get buffer size
  213. * @param
  214. * a_phBitsHandle [IN/OUT] The bits handle
  215. * @par Returns
  216. * VAL_BOOL_T, return buffer size
  217. */
  218. VAL_UINT32_T eBufGetBufSize(VAL_HANDLE_T *a_phBitsHandle);
  219. /**
  220. * @par Function
  221. * NextBytesAlignment
  222. * @par Description
  223. * The function is used to jump bitstream pointer to next bytesalignment
  224. * @param
  225. * a_phBitsHandle [IN/OUT] The bits handle
  226. * @param
  227. * nBytesAlignment [IN] BytesAlignment
  228. * @par Returns
  229. * void
  230. */
  231. void NextBytesAlignment(VAL_HANDLE_T *a_phBitsHandle, VAL_UINT32_T nBytesAlignment);
  232. /**
  233. * @par Function
  234. * eBufInitBS
  235. * @par Description
  236. * The function is used to init bit stream
  237. * @param
  238. * a_phBitsHandle [IN/OUT] The bits handle
  239. * @param
  240. * cmd_queue [IN] command queue
  241. * @param
  242. * pIndex [IN] command queue index
  243. * @par Returns
  244. * VAL_BOOL_T, return VAL_TRUE if success, return VAL_FALSE if failed
  245. */
  246. VAL_BOOL_T eBufInitBS(VAL_HANDLE_T *a_phBitsHandle, P_VCODEC_DRV_CMD_T cmd_queue, VAL_UINT32_T *pIndex);
  247. /**
  248. * @par Function
  249. * eBufGetPAddr
  250. * @par Description
  251. * The function is used to get physical address
  252. * @param
  253. * a_phBitsHandle [IN/OUT] The bits handle
  254. * @par Returns
  255. * VAL_UINT32_T, return physical address
  256. */
  257. VAL_UINT32_T eBufGetPAddr(VAL_HANDLE_T *a_phBitsHandle);
  258. /**
  259. * @par Function
  260. * eBufGetPAddr
  261. * @par Description
  262. * The function is used to re init
  263. * @param
  264. * a_phBitsHandle [IN/OUT] The bits handle
  265. * @param
  266. * nBytes [IN] The Bytes
  267. * @param
  268. * nBits [IN] The Bits
  269. * @par Returns
  270. * VAL_BOOL_T, return VAL_TRUE if success, return VAL_FALSE if failed
  271. */
  272. VAL_BOOL_T eBufReInite(VAL_HANDLE_T *a_phBitsHandle, VAL_UINT32_T nBytes, VAL_UINT32_T nBits);
  273. #ifdef __cplusplus
  274. }
  275. #endif
  276. #endif /* #ifndef _VAL_API_H_ */