qmf.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. /*!
  63. \file qmf.h
  64. \brief Complex qmf analysis/synthesis
  65. \author Markus Werner
  66. */
  67. #ifndef __QMF_H
  68. #define __QMF_H
  69. #include "common_fix.h"
  70. #include "FDK_tools_rom.h"
  71. #include "dct.h"
  72. /*
  73. * Filter coefficient type definition
  74. */
  75. #ifdef QMF_DATA_16BIT
  76. #define FIXP_QMF FIXP_SGL
  77. #define FX_DBL2FX_QMF FX_DBL2FX_SGL
  78. #define FX_QMF2FX_DBL FX_SGL2FX_DBL
  79. #define QFRACT_BITS FRACT_BITS
  80. #else
  81. #define FIXP_QMF FIXP_DBL
  82. #define FX_DBL2FX_QMF
  83. #define FX_QMF2FX_DBL
  84. #define QFRACT_BITS DFRACT_BITS
  85. #endif
  86. /* ARM neon optimized QMF analysis filter requires 32 bit input.
  87. Implemented for RVCT only, currently disabled. See src/arm/qmf_arm.cpp:45 */
  88. #define FIXP_QAS FIXP_PCM
  89. #define QAS_BITS SAMPLE_BITS
  90. #ifdef QMFSYN_STATES_16BIT
  91. #define FIXP_QSS FIXP_SGL
  92. #define QSS_BITS FRACT_BITS
  93. #else
  94. #define FIXP_QSS FIXP_DBL
  95. #define QSS_BITS DFRACT_BITS
  96. #endif
  97. /* Flags for QMF intialization */
  98. /* Low Power mode flag */
  99. #define QMF_FLAG_LP 1
  100. /* Filter is not symetric. This flag is set internally in the QMF initialization as required. */
  101. #define QMF_FLAG_NONSYMMETRIC 2
  102. /* Complex Low Delay Filter Bank (or std symmetric filter bank) */
  103. #define QMF_FLAG_CLDFB 4
  104. /* Flag indicating that the states should be kept. */
  105. #define QMF_FLAG_KEEP_STATES 8
  106. /* Complex Low Delay Filter Bank used in MPEG Surround Encoder */
  107. #define QMF_FLAG_MPSLDFB 16
  108. /* Complex Low Delay Filter Bank used in MPEG Surround Encoder allows a optimized calculation of the modulation in qmfForwardModulationHQ() */
  109. #define QMF_FLAG_MPSLDFB_OPTIMIZE_MODULATION 32
  110. /* Flag to indicate HE-AAC down-sampled SBR mode (decoder) -> adapt analysis post twiddling */
  111. #define QMF_FLAG_DOWNSAMPLED 64
  112. typedef struct
  113. {
  114. int lb_scale; /*!< Scale of low band area */
  115. int ov_lb_scale; /*!< Scale of adjusted overlap low band area */
  116. int hb_scale; /*!< Scale of high band area */
  117. int ov_hb_scale; /*!< Scale of adjusted overlap high band area */
  118. } QMF_SCALE_FACTOR;
  119. struct QMF_FILTER_BANK
  120. {
  121. const FIXP_PFT *p_filter; /*!< Pointer to filter coefficients */
  122. void *FilterStates; /*!< Pointer to buffer of filter states
  123. FIXP_PCM in analyse and
  124. FIXP_DBL in synthesis filter */
  125. int FilterSize; /*!< Size of prototype filter. */
  126. const FIXP_QTW *t_cos; /*!< Modulation tables. */
  127. const FIXP_QTW *t_sin;
  128. int filterScale; /*!< filter scale */
  129. int no_channels; /*!< Total number of channels (subbands) */
  130. int no_col; /*!< Number of time slots */
  131. int lsb; /*!< Top of low subbands */
  132. int usb; /*!< Top of high subbands */
  133. int outScalefactor; /*!< Scale factor of output data (syn only) */
  134. FIXP_DBL outGain; /*!< Gain output data (syn only) (init with 0x80000000 to ignore) */
  135. UINT flags; /*!< flags */
  136. UCHAR p_stride; /*!< Stride Factor of polyphase filters */
  137. };
  138. typedef struct QMF_FILTER_BANK *HANDLE_QMF_FILTER_BANK;
  139. void
  140. qmfAnalysisFiltering( HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf Analysis Bank */
  141. FIXP_QMF **qmfReal, /*!< Pointer to real subband slots */
  142. FIXP_QMF **qmfImag, /*!< Pointer to imag subband slots */
  143. QMF_SCALE_FACTOR *scaleFactor, /*!< Scale factors of QMF data */
  144. const INT_PCM *timeIn, /*!< Time signal */
  145. const int stride, /*!< Stride factor of audio data */
  146. FIXP_QMF *pWorkBuffer /*!< pointer to temporal working buffer */
  147. );
  148. void
  149. qmfSynthesisFiltering( HANDLE_QMF_FILTER_BANK synQmf, /*!< Handle of Qmf Synthesis Bank */
  150. FIXP_QMF **QmfBufferReal, /*!< Pointer to real subband slots */
  151. FIXP_QMF **QmfBufferImag, /*!< Pointer to imag subband slots */
  152. const QMF_SCALE_FACTOR *scaleFactor, /*!< Scale factors of QMF data */
  153. const int ov_len, /*!< Length of band overlap */
  154. INT_PCM *timeOut, /*!< Time signal */
  155. const int stride, /*!< Stride factor of audio data */
  156. FIXP_QMF *pWorkBuffer /*!< pointer to temporal working buffer */
  157. );
  158. int
  159. qmfInitAnalysisFilterBank( HANDLE_QMF_FILTER_BANK h_Qmf, /*!< QMF Handle */
  160. FIXP_QAS *pFilterStates, /*!< Pointer to filter state buffer */
  161. int noCols, /*!< Number of time slots */
  162. int lsb, /*!< Number of lower bands */
  163. int usb, /*!< Number of upper bands */
  164. int no_channels, /*!< Number of critically sampled bands */
  165. int flags); /*!< Flags */
  166. void
  167. qmfAnalysisFilteringSlot( HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf Synthesis Bank */
  168. FIXP_QMF *qmfReal, /*!< Low and High band, real */
  169. FIXP_QMF *qmfImag, /*!< Low and High band, imag */
  170. const INT_PCM *timeIn, /*!< Pointer to input */
  171. const int stride, /*!< stride factor of input */
  172. FIXP_QMF *pWorkBuffer /*!< pointer to temporal working buffer */
  173. );
  174. int
  175. qmfInitSynthesisFilterBank( HANDLE_QMF_FILTER_BANK h_Qmf, /*!< QMF Handle */
  176. FIXP_QSS *pFilterStates, /*!< Pointer to filter state buffer */
  177. int noCols, /*!< Number of time slots */
  178. int lsb, /*!< Number of lower bands */
  179. int usb, /*!< Number of upper bands */
  180. int no_channels, /*!< Number of critically sampled bands */
  181. int flags); /*!< Flags */
  182. void qmfSynthesisFilteringSlot( HANDLE_QMF_FILTER_BANK synQmf,
  183. const FIXP_QMF *realSlot,
  184. const FIXP_QMF *imagSlot,
  185. const int scaleFactorLowBand,
  186. const int scaleFactorHighBand,
  187. INT_PCM *timeOut,
  188. const int stride,
  189. FIXP_QMF *pWorkBuffer);
  190. void
  191. qmfChangeOutScalefactor (HANDLE_QMF_FILTER_BANK synQmf, /*!< Handle of Qmf Synthesis Bank */
  192. int outScalefactor /*!< New scaling factor for output data */
  193. );
  194. void
  195. qmfChangeOutGain (HANDLE_QMF_FILTER_BANK synQmf, /*!< Handle of Qmf Synthesis Bank */
  196. FIXP_DBL outputGain /*!< New gain for output data */
  197. );
  198. #endif /* __QMF_H */