wav_file.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. /************************** Fraunhofer IIS FDK SysLib **********************
  63. Author(s): Eric Allamanche
  64. ******************************************************************************/
  65. /** \file wav_file.h
  66. * \brief Rudimentary WAVE file read/write support.
  67. *
  68. * The WAVE file reader/writer is intented to be used in the codec's example
  69. * framework for easily getting started with encoding/decoding. Therefore
  70. * it serves mainly for helping quickly understand how a codec's API actually
  71. * works.
  72. * Being a WAVE file reader/writer with very basic functionality, it may not be
  73. * able to read WAVE files that come with unusual configurations.
  74. * Details on how to use the interface functions can be found in every
  75. * (encoder/decoder) example framework.
  76. */
  77. #ifndef __WAV_FILE_H__
  78. #define __WAV_FILE_H__
  79. #include "genericStds.h"
  80. #ifdef __cplusplus
  81. extern "C" {
  82. #endif
  83. #define SPEAKER_FRONT_LEFT 0x1
  84. #define SPEAKER_FRONT_RIGHT 0x2
  85. #define SPEAKER_FRONT_CENTER 0x4
  86. #define SPEAKER_LOW_FREQUENCY 0x8
  87. #define SPEAKER_BACK_LEFT 0x10
  88. #define SPEAKER_BACK_RIGHT 0x20
  89. #define SPEAKER_FRONT_LEFT_OF_CENTER 0x40
  90. #define SPEAKER_FRONT_RIGHT_OF_CENTER 0x80
  91. #define SPEAKER_BACK_CENTER 0x100
  92. #define SPEAKER_SIDE_LEFT 0x200
  93. #define SPEAKER_SIDE_RIGHT 0x400
  94. #define SPEAKER_TOP_CENTER 0x800
  95. #define SPEAKER_TOP_FRONT_LEFT 0x1000
  96. #define SPEAKER_TOP_FRONT_CENTER 0x2000
  97. #define SPEAKER_TOP_FRONT_RIGHT 0x4000
  98. #define SPEAKER_TOP_BACK_LEFT 0x8000
  99. #define SPEAKER_TOP_BACK_CENTER 0x10000
  100. #define SPEAKER_TOP_BACK_RIGHT 0x20000
  101. #define SPEAKER_RESERVED 0x80000000
  102. /*!
  103. * RIFF WAVE file struct.
  104. * For details see WAVE file format documentation (for example at http://www.wotsit.org).
  105. */
  106. typedef struct WAV_HEADER
  107. {
  108. char riffType[4];
  109. UINT riffSize;
  110. char waveType[4];
  111. char formatType[4];
  112. UINT formatSize;
  113. USHORT compressionCode;
  114. USHORT numChannels;
  115. UINT sampleRate;
  116. UINT bytesPerSecond;
  117. USHORT blockAlign;
  118. USHORT bitsPerSample;
  119. char dataType[4];
  120. UINT dataSize;
  121. } WAV_HEADER;
  122. struct WAV
  123. {
  124. WAV_HEADER header;
  125. FDKFILE *fp;
  126. UINT channelMask;
  127. };
  128. typedef struct WAV *HANDLE_WAV;
  129. /**
  130. * \brief Open a WAV file handle for reading.
  131. *
  132. * \param pWav Pointer to a memory location, where a WAV handle is returned.
  133. * \param filename File name to be opened.
  134. *
  135. * \return 0 on success and non-zero on failure.
  136. */
  137. INT WAV_InputOpen (HANDLE_WAV *pWav, const char *filename);
  138. /**
  139. * \brief Read samples from a WAVE file. The samples are automatically re-ordered to the
  140. * native host endianess and scaled to full scale of the INT_PCM type, from
  141. * whatever BPS the WAVE file had specified in its header data.
  142. *
  143. * \param wav Handle of WAV file.
  144. * \param sampleBuffer Pointer to store audio data.
  145. * \param numSamples Desired number of samples to read.
  146. * \param nBufBits Size in bit of each audio sample of sampleBuffer.
  147. *
  148. * \return Number of samples actually read.
  149. */
  150. INT WAV_InputRead (HANDLE_WAV wav, void *sampleBuffer, UINT numSamples, int nBufBits);
  151. /**
  152. * \brief Close a WAV file reading handle.
  153. * \param pWav Pointer to a WAV file reading handle.
  154. * \return void
  155. */
  156. void WAV_InputClose(HANDLE_WAV *pWav);
  157. /**
  158. * \brief Open WAV output/writer handle.
  159. *
  160. * \param pWav Pointer to WAV handle to be returned.
  161. * \param outputFilename File name of the file to be written to.
  162. * \param sampleRate Desired samplerate of the resulting WAV file.
  163. * \param numChannels Desired number of audio channels of the resulting WAV file.
  164. * \param bitsPerSample Desired number of bits per audio sample of the resulting WAV file.
  165. *
  166. * \return 0: ok; -1: error
  167. */
  168. INT WAV_OutputOpen(HANDLE_WAV *pWav, const char *outputFilename, INT sampleRate, INT numChannels, INT bitsPerSample);
  169. /**
  170. * \brief Write data to WAV file asociated to WAV handle.
  171. *
  172. * \param wav Handle of WAV file
  173. * \param sampleBuffer Pointer to audio samples, right justified integer values.
  174. * \param numberOfSamples The number of individual audio sample valuesto be written.
  175. * \param nBufBits Size in bits of each audio sample in sampleBuffer.
  176. * \param nSigBits Amount of significant bits of each nBufBits in sampleBuffer.
  177. *
  178. * \return 0: ok; -1: error
  179. */
  180. INT WAV_OutputWrite(HANDLE_WAV wav, void *sampleBuffer, UINT numberOfSamples, int nBufBits, int nSigBits);
  181. /**
  182. * \brief Close WAV output handle.
  183. * \param pWav Pointer to WAV handle. *pWav is set to NULL.
  184. * \return void
  185. */
  186. void WAV_OutputClose(HANDLE_WAV *pWav);
  187. #ifdef __cplusplus
  188. }
  189. #endif
  190. #endif /* __WAV_FILE_H__ */