aacdec.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*****************************************************************************
  2. * Copyright 2004 - 2050, Hisilicon Tech. Co., Ltd.
  3. * ALL RIGHTS RESERVED
  4. * FileName: aacdec.h
  5. * Description:
  6. *
  7. * History:
  8. * Version Date Author DefectNum Description
  9. * 0.01 2006-11-01 z40717 NULL Create this file.
  10. *
  11. *****************************************************************************/
  12. /**
  13. * \file
  14. * \brief Describes the information about AACDEC.
  15. */
  16. #ifndef _AACDEC_H
  17. #define _AACDEC_H
  18. #ifdef __cplusplus
  19. #if __cplusplus
  20. extern "C" {
  21. #endif /* __cpluscplus */
  22. #endif /* __cpluscplus */
  23. #include "hi_type.h"
  24. /********************************Macro Definition********************************/
  25. /** \addtogroup AACDEC */
  26. /** @{ */ /** <!-- [AACDEC] */
  27. #ifndef AAC_MAX_NCHANS
  28. #define AAC_MAX_NCHANS 2
  29. #endif
  30. #define AAC_MAX_NSAMPS 1024
  31. #define AAC_MAINBUF_SIZE (768 * AAC_MAX_NCHANS) /**<according to spec (13818-7 section 8.2.2, 14496-3 section 4.5.3),6144 bits = 768 bytes per SCE or CCE-I,12288 bits = 1536 bytes per CPE*/
  32. #define AAC_NUM_PROFILES 3
  33. #define AAC_PROFILE_MP 0
  34. #define AAC_PROFILE_LC 1
  35. #define AAC_PROFILE_SSR 2
  36. #ifndef HI_SUCCESS
  37. #define HI_SUCCESS 0
  38. #endif
  39. /** @} */ /** <!-- ==== Macro Definition end ==== */
  40. /*************************** Structure Definition ****************************/
  41. /** \addtogroup AACDEC */
  42. /** @{ */ /** <!-- [AACDEC] */
  43. /**Defines AACDEC error code*/
  44. typedef enum
  45. {
  46. ERR_AAC_NONE = 0, /**<no decode error*/
  47. ERR_AAC_INDATA_UNDERFLOW = -1, /**<not enough input data*/
  48. ERR_AAC_NULL_POINTER = -2, /**<null pointer*/
  49. ERR_AAC_INVALID_ADTS_HEADER = -3, /**<invalid adts header*/
  50. ERR_AAC_INVALID_ADIF_HEADER = -4, /**<invalid adif header*/
  51. ERR_AAC_INVALID_FRAME = -5, /**<invalid frame*/
  52. ERR_AAC_MPEG4_UNSUPPORTED = -6, /**<upsupport mpeg4 format*/
  53. ERR_AAC_CHANNEL_MAP = -7, /**<channel map error*/
  54. ERR_AAC_SYNTAX_ELEMENT = -8, /**<element error*/
  55. ERR_AAC_DEQUANT = -9, /**<dequant error*/
  56. ERR_AAC_STEREO_PROCESS = -10, /**<stereo process error*/
  57. ERR_AAC_PNS = -11, /**<pns process error*/
  58. ERR_AAC_SHORT_BLOCK_DEINT = -12, /**<reserved*/
  59. ERR_AAC_TNS = -13, /**<TNS process error*/
  60. ERR_AAC_IMDCT = -14, /**<IMDCT process error*/
  61. ERR_AAC_NCHANS_TOO_HIGH = -15, /**<unsupport mutil channel*/
  62. ERR_AAC_SBR_INIT = -16, /**<SBR init error*/
  63. ERR_AAC_SBR_BITSTREAM = -17, /**<SBR bitstream error*/
  64. ERR_AAC_SBR_DATA = -18, /**<SBR data error*/
  65. ERR_AAC_SBR_PCM_FORMAT = -19, /**<SBR pcm data error*/
  66. ERR_AAC_SBR_NCHANS_TOO_HIGH = -20, /**<unsupport SBR multi channel*/
  67. ERR_AAC_SBR_SINGLERATE_UNSUPPORTED = -21, /**<SBR invalid samplerate*/
  68. ERR_AAC_RAWBLOCK_PARAMS = -22, /**<invalid RawBlock params*/
  69. ERR_AAC_PS_INIT = -23, /**<PS init error*/
  70. ERR_AAC_CH_MAPPING = -24,
  71. ERR_UNKNOWN = -9999 /**<reserved*/
  72. } HI_AACDEC_ERR_E;
  73. typedef struct _AACFrameInfo
  74. {
  75. int bitRate;
  76. int nChans; /**<channels,range:1,2*/
  77. int sampRateCore; /**<inner sample rate*/
  78. int sampRateOut; /**<output samplerate*/
  79. int bitsPerSample; /**<bitwidth ,range:16*/
  80. int outputSamps; /**<output samples*/
  81. int profile; /**<profile*/
  82. int tnsUsed; /**<tns tools*/
  83. int pnsUsed; /**<pns tools*/
  84. } AACFrameInfo;
  85. typedef enum
  86. {
  87. AACDEC_ADTS = 0,
  88. AACDEC_LOAS = 1,
  89. AACDEC_LATM_MCP1 = 2,
  90. } AACDECTransportType;
  91. typedef void* HAACDecoder;
  92. typedef struct hiAACDEC_VERSION_S
  93. {
  94. HI_U8 aVersion[64];
  95. } AACDEC_VERSION_S;
  96. /** @} */ /** <!-- ==== Structure Definition End ==== */
  97. /******************************* API declaration *****************************/
  98. /** \addtogroup AACDEC */
  99. /** @{ */ /** <!-- [AACDEC]*/
  100. /**
  101. \brief Get version information.
  102. \attention \n
  103. N/A
  104. \param[in] pVersion : version describe struct
  105. \retval ::HI_SUCCESS : Success
  106. \retval ::HI_FAILURE : pVersion is NULL, return HI_FAILURE
  107. \see \n
  108. N/A
  109. */
  110. HI_S32 HI_AACDEC_GetVersion(AACDEC_VERSION_S* pVersion);
  111. /**
  112. \brief create and initial decoder device.
  113. \attention \n
  114. N/A
  115. \param[in] enTranType : transport type
  116. \retval ::HAACDecoder : init success, return non-NULL handle.
  117. \retval ::NULL : init failure, return NULL
  118. \see \n
  119. N/A
  120. */
  121. HAACDecoder AACInitDecoder(AACDECTransportType enTranType);
  122. /**
  123. \brief destroy AAC-Decoder, free the memory.
  124. \attention \n
  125. N/A
  126. \param[in] hAACDecoder : AAC-Decoder handle
  127. \see \n
  128. N/A
  129. */
  130. HI_VOID AACFreeDecoder(HAACDecoder hAACDecoder);
  131. /**
  132. \brief set RawMode before decode Raw Format aac bitstream(Reserved API, unused now.)
  133. \attention \n
  134. N/A
  135. \param[in] hAACDecoder : AAC-Decoder handle
  136. \param[in] nChans : inout channels
  137. \param[in] sampRate : input sampelrate
  138. \retval ::HI_FAILURE : RESERVED API, always return HI_FAILURE.
  139. \see \n
  140. N/A
  141. */
  142. HI_S32 AACSetRawMode(HAACDecoder hAACDecoder, HI_S32 nChans, HI_S32 sampRate);
  143. /**
  144. \brief look for valid AAC sync header
  145. \attention \n
  146. N/A
  147. \param[in] hAACDecoder : AAC-Decoder handle
  148. \param[in/out] ppInbufPtr : address of the pointer of start-point of the bitstream
  149. \param[in/out] pBytesLeft : pointer to BytesLeft that indicates bitstream numbers at input buffer
  150. \retval ::<0 : err, always return ERR_AAC_INDATA_UNDERFLOW
  151. \retval ::other : Success, return number bytes of current frame
  152. \see \n
  153. N/A
  154. */
  155. HI_S32 AACDecodeFindSyncHeader(HAACDecoder hAACDecoder, HI_U8** ppInbufPtr, HI_S32* pBytesLeft);
  156. /**
  157. \brief decoding AAC frame and output 1024(LC) OR 2048(HEAAC/eAAC/eAAC+) 16bit PCM samples per channel.
  158. \attention \n
  159. \param[in] hAACDecoder : AAC-Decoder handle
  160. \param[in] ppInbufPtr : address of the pointer of start-point of the bitstream
  161. \param[in/out] pBytesLeft : pointer to BytesLeft that indicates bitstream numbers at input buffer,indicates the left bytes
  162. \param[in] pOutPcm : the address of the out pcm buffer,pcm data in noninterlaced fotmat: L/L/L/... R/R/R/...
  163. \retval :: SUCCESS : Success
  164. \retval :: ERROR_CODE : FAILURE, return error_code.
  165. \see \n
  166. N/A
  167. */
  168. HI_S32 AACDecodeFrame(HAACDecoder hAACDecoder, HI_U8** ppInbufPtr, HI_S32* pBytesLeft, HI_S16* pOutPcm);
  169. /**
  170. \brief get the frame information.
  171. \attention \n
  172. \param[in] hAACDecoder : AAC-Decoder handle
  173. \param[out] aacFrameInfo : frame information
  174. \retval :: HI_SUCCESS : Success
  175. \retval :: ERROR_CODE : FAILURE, return error_code.
  176. \see \n
  177. N/A
  178. */
  179. HI_S32 AACGetLastFrameInfo(HAACDecoder hAACDecoder, AACFrameInfo* aacFrameInfo);
  180. /**
  181. \brief set eosflag.
  182. \attention \n
  183. \param[in] hAACDecoder : AAC-Decoder handle
  184. \param[in] s32Eosflag : end flag
  185. \retval :: HI_SUCCESS : Success
  186. \retval :: ERROR_CODE : FAILURE, return error_code.
  187. \see \n
  188. N/A
  189. */
  190. HI_S32 AACDecoderSetEosFlag(HAACDecoder hAACDecoder, HI_S32 s32Eosflag);
  191. /**
  192. \brief flush internal codec state (after seeking, for example)
  193. \attention \n
  194. \param[in] hAACDecoder : AAC-Decoder handle
  195. \retval :: HI_SUCCESS : Success
  196. \retval :: ERROR_CODE : FAILURE, return error_code.
  197. \see \n
  198. N/A
  199. */
  200. HI_S32 AACFlushCodec(HAACDecoder hAACDecoder);
  201. /** @} */ /** <!-- ==== API declaration end ==== */
  202. #ifdef __cplusplus
  203. #if __cplusplus
  204. }
  205. #endif /* __cpluscplus */
  206. #endif /* __cpluscplus */
  207. #endif /* _AACDEC_H */