FDK_crc.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /* -----------------------------------------------------------------------------------------------------------
  2. Software License for The Fraunhofer FDK AAC Codec Library for Android
  3. © Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
  4. All rights reserved.
  5. 1. INTRODUCTION
  6. The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
  7. the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
  8. This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
  9. AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
  10. audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
  11. independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
  12. of the MPEG specifications.
  13. Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
  14. may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
  15. individually for the purpose of encoding or decoding bit streams in products that are compliant with
  16. the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
  17. these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
  18. software may already be covered under those patent licenses when it is used for those licensed purposes only.
  19. Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
  20. are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
  21. applications information and documentation.
  22. 2. COPYRIGHT LICENSE
  23. Redistribution and use in source and binary forms, with or without modification, are permitted without
  24. payment of copyright license fees provided that you satisfy the following conditions:
  25. You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
  26. your modifications thereto in source code form.
  27. You must retain the complete text of this software license in the documentation and/or other materials
  28. provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
  29. You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
  30. modifications thereto to recipients of copies in binary form.
  31. The name of Fraunhofer may not be used to endorse or promote products derived from this library without
  32. prior written permission.
  33. You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
  34. software or your modifications thereto.
  35. Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
  36. and the date of any change. For modified versions of the FDK AAC Codec, the term
  37. "Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
  38. "Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
  39. 3. NO PATENT LICENSE
  40. NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
  41. ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
  42. respect to this software.
  43. You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
  44. by appropriate patent licenses.
  45. 4. DISCLAIMER
  46. This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
  47. "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
  48. of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  49. CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
  50. including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
  51. or business interruption, however caused and on any theory of liability, whether in contract, strict
  52. liability, or tort (including negligence), arising in any way out of the use of this software, even if
  53. advised of the possibility of such damage.
  54. 5. CONTACT INFORMATION
  55. Fraunhofer Institute for Integrated Circuits IIS
  56. Attention: Audio and Multimedia Departments - FDK AAC LL
  57. Am Wolfsmantel 33
  58. 91058 Erlangen, Germany
  59. www.iis.fraunhofer.de/amm
  60. [email protected]
  61. ----------------------------------------------------------------------------------------------------------- */
  62. /******************************** MPEG Audio Encoder **************************
  63. Initial author:
  64. contents/description: CRC calculation
  65. ******************************************************************************/
  66. #ifndef FDK_CRC_H
  67. #define FDK_CRC_H
  68. #include "FDK_bitstream.h"
  69. #define MAX_CRC_REGS 3 /*!< Maximal number of overlapping crc region in ADTS channel pair element is two.
  70. Select three independent regions preventively. */
  71. /**
  72. * This structure describes single crc region used for crc calculation.
  73. */
  74. typedef struct
  75. {
  76. UCHAR isActive;
  77. INT maxBits;
  78. UINT bitBufCntBits;
  79. UINT validBits;
  80. } CCrcRegData;
  81. /**
  82. * CRC info structure.
  83. */
  84. typedef struct
  85. {
  86. CCrcRegData crcRegData[MAX_CRC_REGS]; /*!< Multiple crc region description. */
  87. const USHORT *pCrcLookup; /*!< Pointer to lookup table filled in FDK_crcInit(). */
  88. USHORT crcPoly; /*!< CRC generator polynom. */
  89. USHORT crcMask; /*!< CRC mask. */
  90. USHORT startValue; /*!< CRC start value. */
  91. UCHAR crcLen; /*!< CRC length. */
  92. UINT regStart; /*!< Start region marker for synchronization. */
  93. UINT regStop; /*!< Stop region marker for synchronization. */
  94. USHORT crcValue; /*!< Crc value to be calculated. */
  95. } FDK_CRCINFO;
  96. /**
  97. * CRC info handle.
  98. */
  99. typedef FDK_CRCINFO* HANDLE_FDK_CRCINFO;
  100. /**
  101. * \brief Initialize CRC structure.
  102. *
  103. * The function initializes existing crc info structure with denoted configuration.
  104. *
  105. * \param hCrcInfo Pointer to an outlying allocated crc info structure.
  106. * \param crcPoly Configure crc polynom.
  107. * \param crcStartValue Configure crc start value.
  108. * \param crcLen Configure crc length.
  109. *
  110. * \return none
  111. */
  112. void FDKcrcInit(
  113. HANDLE_FDK_CRCINFO hCrcInfo,
  114. const UINT crcPoly,
  115. const UINT crcStartValue,
  116. const UINT crcLen
  117. );
  118. /**
  119. * \brief Reset CRC info structure.
  120. *
  121. * This function clears all intern states of the crc structure.
  122. *
  123. * \param hCrcInfo Pointer to crc info stucture.
  124. *
  125. * \return none
  126. */
  127. void FDKcrcReset(
  128. HANDLE_FDK_CRCINFO hCrcInfo
  129. );
  130. /**
  131. * \brief Start CRC region with maximum number of bits.
  132. *
  133. * This function marks position in bitstream to be used as start point for crc calculation.
  134. * Bitstream range for crc calculation can be limited or kept dynamic depending on mBits parameter.
  135. * The crc region has to be terminated with FDKcrcEndReg() in each case.
  136. *
  137. * \param hCrcInfo Pointer to crc info stucture.
  138. * \param hBs Pointer to current bit buffer structure.
  139. * \param mBits Number of bits in crc region to be calculated.
  140. * - mBits > 0: Zero padding will be used for CRC calculation, if there
  141. * are less than mBits bits available.
  142. * - mBits < 0: No zero padding is done.
  143. * - mBits = 0: The number of bits used in crc calculation is dynamically,
  144. * depending on bitstream position between FDKcrcStartReg() and
  145. * FDKcrcEndReg() call.
  146. *
  147. * \return ID for the created region, -1 in case of an error
  148. */
  149. INT FDKcrcStartReg(
  150. HANDLE_FDK_CRCINFO hCrcInfo,
  151. const HANDLE_FDK_BITSTREAM hBs,
  152. const INT mBits
  153. );
  154. /**
  155. * \brief Ends CRC region.
  156. *
  157. * This function terminates crc region specified with FDKcrcStartReg(). The number of bits in crc region depends
  158. * on mBits parameter of FDKcrcStartReg().
  159. * This function calculates and updates crc in info structure.
  160. *
  161. * \param hCrcInfo Pointer to crc info stucture.
  162. * \param hBs Pointer to current bit buffer structure.
  163. * \param reg Crc region ID created in FDKcrcStartReg().
  164. *
  165. * \return 0 on success
  166. */
  167. INT FDKcrcEndReg(
  168. HANDLE_FDK_CRCINFO hCrcInfo,
  169. const HANDLE_FDK_BITSTREAM hBs,
  170. const INT reg
  171. );
  172. /**
  173. * \brief This function returns crc value from info struct.
  174. *
  175. * \param hCrcInfo Pointer to crc info stucture.
  176. *
  177. * \return CRC value masked with crc length.
  178. */
  179. USHORT FDKcrcGetCRC(
  180. const HANDLE_FDK_CRCINFO hCrcInfo
  181. );
  182. #endif /* FDK_CRC_H */