aacenc.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*****************************************************************************
  2. * Copyright 2004 - 2018, Hisilicon Tech. Co., Ltd.
  3. * ALL RIGHTS RESERVED
  4. * FileName: hi_spdif.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 AACENC.
  15. */
  16. #ifndef _AACENC_H
  17. #define _AACENC_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 AACENC */
  26. /** @{ */ /** <!-- [AACENC] */
  27. #ifdef MONO_ONLY
  28. #define MAX_CHANNELS 1 /**<aacenc encoder channels*/
  29. #else
  30. #define MAX_CHANNELS 2
  31. #endif
  32. #define AACENC_BLOCKSIZE 1024 /**<aacenc blocksize*/
  33. /** @} */ /** <!-- ==== Macro Definition end ==== */
  34. /*************************** Structure Definition ****************************/
  35. /** \addtogroup AACENC */
  36. /** @{ */ /** <!-- [AACENC] */
  37. typedef enum
  38. {
  39. HI_AACENC_OK = 0x0000, /*!< No error happened. All fine. */
  40. HI_AACENC_INVALID_HANDLE = 0x0020, /*!< Handle passed to function call was invalid. */
  41. HI_AACENC_MEMORY_ERROR = 0x0021, /*!< Memory allocation failed. */
  42. HI_AACENC_UNSUPPORTED_PARAMETER = 0x0022, /*!< Parameter not available. */
  43. HI_AACENC_INVALID_CONFIG = 0x0023, /*!< Configuration not provided. */
  44. HI_AACENC_INIT_ERROR = 0x0040, /*!< General initialization error. */
  45. HI_AACENC_INIT_AAC_ERROR = 0x0041, /*!< AAC library initialization error. */
  46. HI_AACENC_INIT_SBR_ERROR = 0x0042, /*!< SBR library initialization error. */
  47. HI_AACENC_INIT_TP_ERROR = 0x0043, /*!< Transport library initialization error. */
  48. HI_AACENC_INIT_META_ERROR = 0x0044, /*!< Meta data library initialization error. */
  49. HI_AACENC_ENCODE_ERROR = 0x0060, /*!< The encoding process was interrupted by an unexpected error. */
  50. HI_AACENC_ENCODE_EOF = 0x0080 /*!< End of file reached. */
  51. } HI_AACENC_ERROR_E;
  52. /**Defines AACENC quality*/
  53. typedef enum
  54. {
  55. AU_QualityExcellent = 0,
  56. AU_QualityHigh = 1,
  57. AU_QualityMedium = 2,
  58. AU_QualityLow = 3,
  59. } AuQuality;
  60. /**Defines AACENC format*/
  61. typedef enum
  62. {
  63. AACLC = 0, /**<AAC-LC format*/
  64. EAAC = 1, /**<HEAAC or AAC+ or aacPlusV1*/
  65. EAACPLUS = 2, /**<AAC++ or aacPlusV2*/
  66. AACLD = 3, /**<AAC LD(Low Delay)*/
  67. AACELD = 4, /**<AAC ELD(Low Delay)*/
  68. } AuEncoderFormat;
  69. /**Defines AACENC container*/
  70. typedef enum
  71. {
  72. AACENC_ADTS = 0,
  73. AACENC_LOAS = 1,
  74. AACENC_LATM_MCP1 = 2,
  75. } AACENCTransportType;
  76. /**Defines AACENC configuration*/
  77. typedef struct
  78. {
  79. AuQuality quality;
  80. AuEncoderFormat coderFormat;
  81. HI_S16 bitsPerSample;
  82. HI_S32 sampleRate; /**<audio file sample rate */
  83. HI_S32 bitRate; /**<encoder bit rate in bits/sec */
  84. HI_S16 nChannelsIn; /**<number of channels on input (1,2) */
  85. HI_S16 nChannelsOut; /**<number of channels on output (1,2) */
  86. HI_S16 bandWidth; /**<targeted audio bandwidth in Hz */
  87. AACENCTransportType transtype;
  88. } AACENC_CONFIG;
  89. /**Defines AACENC version*/
  90. typedef struct hiAACENC_VERSION_S
  91. {
  92. HI_U8 aVersion[64];
  93. } AACENC_VERSION_S;
  94. typedef HI_U32 AAC_ENCODER_S;
  95. /** @} */ /** <!-- ==== Structure Definition End ==== */
  96. /******************************* API declaration *****************************/
  97. /** \addtogroup AACENC */
  98. /** @{ */ /** <!-- [AACENC] */
  99. /**
  100. \brief Get version information.
  101. \attention \n
  102. N/A
  103. \param[in] pVersion version describe struct
  104. \retval ::HI_SUCCESS : Success
  105. \retval ::HI_FAILURE : FAILURE
  106. \see \n
  107. N/A
  108. */
  109. HI_S32 HI_AACENC_GetVersion(AACENC_VERSION_S* pVersion);
  110. /**
  111. \brief get reasonable default configuration.
  112. \attention \n
  113. N/A
  114. \param[in] pstConfig pointer to an configuration information structure
  115. \retval ::HI_SUCCESS : Success
  116. \retval ::HI_FAILURE : FAILURE
  117. \see \n
  118. N/A
  119. */
  120. HI_S32 AACInitDefaultConfig(AACENC_CONFIG* pstConfig);
  121. /**
  122. \brief allocate and initialize a new encoder instance.
  123. \attention \n
  124. N/A
  125. \param[in] phAacPlusEnc pointer to an configuration information structure
  126. \param[in] pstConfig pointer to an configuration information structure
  127. \retval ::HI_SUCCESS : Success
  128. \retval ::HI_FAILURE : FAILURE
  129. \see \n
  130. N/A
  131. */
  132. HI_S32 AACEncoderOpen(AAC_ENCODER_S** phAacPlusEnc, AACENC_CONFIG* pstConfig);
  133. /**
  134. \brief allocate and initialize a new encoder instance
  135. \attention \n
  136. N/A
  137. \param[in] hAacPlusEnc pointer to an configuration information structure
  138. \param[in] ps16PcmBuf BLOCKSIZE*nChannels audio samples,interleaved
  139. \param[in] pu8Outbuf pointer to output buffer,(must be 6144/8*MAX_CHANNELS bytes large)
  140. \param[in] ps32NumOutBytes number of bytes in output buffer after processing
  141. \retval ::HI_SUCCESS : Success
  142. \retval ::HI_FAILURE : FAILURE
  143. \see \n
  144. N/A
  145. */
  146. HI_S32 AACEncoderFrame(AAC_ENCODER_S* hAacPlusEnc, HI_S16* ps16PcmBuf,
  147. HI_U8* pu8Outbuf, HI_S32* ps32NumOutBytes);
  148. /**
  149. \brief close encoder device.
  150. \attention \n
  151. N/A
  152. \param[in] hAacPlusEnc pointer to an configuration information structure
  153. \retval N/A
  154. \see \n
  155. N/A
  156. */
  157. HI_VOID AACEncoderClose (AAC_ENCODER_S* hAacPlusEnc);
  158. /** @} */ /** <!-- ==== API declaration end ==== */
  159. #ifdef __cplusplus
  160. #if __cplusplus
  161. }
  162. #endif /* __cpluscplus */
  163. #endif /* __cpluscplus */
  164. #endif /* _AACENC_H */